Extract values from array inside json #337
-
Hello!
Desired output, which I get from JOLT:
Working JOLT spec:
Any suggestions how to fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
The way to write a transform like this in JSLT is to start with the output you want. Use that as the starting point. Then go through the values and replace them with a JSLT expression that will find the correct value in the input. Use the playground to try it out as you go. If you keep the tutorial open you should be able to do solve the first two pretty much immediately. |
Beta Was this translation helpful? Give feedback.
-
Thanks, this worked!
What if i had more measurements than temperature and wind. What would be a good generic way to get for example all elementIds and values? |
Beta Was this translation helpful? Give feedback.
-
Thank you for your help. I'll take a look at that later! |
Beta Was this translation helpful? Give feedback.
There's a few different ways you can deal with
observations
. The big question is: is the order reliable? It probably isn't.You need to first find the observation that has "air_temperature", and only afterwards can you get the value. Try this:
It will get you an array. Now you need to pick out the first element from it. Unfortunately, you can't just tack on a
[0]
.will do it.
Put the two
let
s at the top and you'll have it.