-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapping of json keys #34
Comments
Hm we can investigate that but full generic mappings are always very dangerous. A lot of bad stuff can happen when using it. Our core concept is that we use a specific topic as a key for a mapping. So when the topic is |
Hi @simeonthefirst , you can try to use the following sample, to generate dynamicaliy new nodes: This will transform the source msg. as follows: If your mapping requires more flexibility, then I recommend using the programmatic approach. This means writing your own mapping class in Java and upload this to the mapper. A sample implementation can be found here. Pls. let me know if this helps. --Christof |
Hi,
|
Hi @simeonthefirst, I added a new setting Could you pls. take a look if this helps and fits for your use case? Regards Christof |
Hi @sagIoTPower , thank you! I did not had the time to test it jet, but took a look at the example. For me it looks like the measurement-/fragmentname can now vary between different pre-known names. Or do i get it wrong? best regards, |
Hi @simeonthefirst, The release v.3.1.7 covers this new strategy. Regards Christof |
I have a usecase, where there are many different measurements and more may also be added over time. To help that i don't want to have a mapping for each measurement, but only one dynamic mapping that covers that.
Threfore i have to map the keys of the source message (eg. /devicename/measurementname { "series-name": 12 } ) to the mqtt message format of cumulocity where the measurement name and series names are keys not values . In this example from a topic to a json key (
[ _TOPIC_LEVEL_[1] -> $keys()[3] ]
) and from a json key to a json key for the series name:[ $keys()[0] -> $keys($eval($keys()[3]))[0] ]
.To put the value into the series i used:
[ $eval($keys($)[0]) -> **.value[0] ]
I know that with that kind of mapping the order of the fragments is relevant what is not json like but i think thats the only option.
I have no experience with jsonata but my queries worked in the online jsonata tester (https://try.jsonata.org/) . The testing in the c8y app seems to have failed (screenshot).
![image](https://private-user-images.githubusercontent.com/50956501/250036199-c9a7dc07-be52-4687-916b-a7a3463f81e2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxMjkwMTgsIm5iZiI6MTcyMjEyODcxOCwicGF0aCI6Ii81MDk1NjUwMS8yNTAwMzYxOTktYzlhN2RjMDctYmU1Mi00Njg3LTkxNmItYTdhMzQ2M2Y4MWUyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI4VDAxMDUxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM0ZGZhZjY1NmM2Mjk4NzhmOWMwMDZlODJiYWQzZWZmZjBlZmY3MzZiNDUzMzliZTRjYjUxMDZjNmE3ZWQ4MDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jg1gKV8qG41AS8C3FsjbH3BEq5bDdFreLK5jgAF2t9I)
Is it in somehow possible to map the keys or is this service limited to value mapping?
The text was updated successfully, but these errors were encountered: