Json Path selects fixed array number

I have a deep nested json file. Seems to be objects and then nested arrays. See my sample project. The first JSON Path node “timeSeries data” goes well.

The second JSON Path node “t for Temperature data” gets into trouble…
With Json Path I select within the first validTime an array of name: ‘t’ and its values [24.2], and right click and add it to the path which creates a path like: $[‘timeSeries’][0][‘parameters’][11][‘values’][0]. The “[11]” indicates that this is the 12th index (0-based) in that particular validTime array. When Ungrouped it gives that particular value of 24.2.

To make this work, getting all temperature values in all of the file I change the path to $[‘timeSeries’][ * ][‘parameters’][11][‘values’][0]. I.e changing the first [0] to [ * ]. (without spaces on either side of the asterix).

And now to the real problem - this always gives me the 12th array - but the Swedish met office sometimes changes the ‘t’ array to another position in the array, so in my example it starts reading the ‘gust’ array when it is in the 12th array.

I read something that one could use some form of [?(‘name’ == ‘t’)] syntax? But inside JSON Path it seems not to work?

Is this also a case of a json file not being correctly configured? I have read that objects can be in any order, but any “arrays should be ordered”. And this is an array of arrays - isn’t it?

SMHI-forcast-json.knwf (17.2 KB)

Would you please provide the json file? Otherwise no one else can see what’s going on.

Hi elsamuel,

Ah, sorry, I forgot to mention that the file is included in the knwf file, and you just have to point the json reader to it. The file name is UppsalaRH20200813,json. I laborated with a file instead of annoying the met office :wink:

I solved the problem for the two JSON Paths for just before I went out with my dog.
For “t for temperature data” the jsonpath is: $…[?(@.name==‘t’)].values
That gets a list of string “[nr]” to ungroup.
For the 3rd JSON Path node just replace the ‘t’ with ‘r’.



I’m going away early morning so it’s time to go to bed here, but will be back sunday evening or monday morning and can load up that fixed phase of the project then.

Now finally got there and fixed the JSON Path to read the data direct from the URL and used both types of jayway jsonpath notations - both the bracket and the dot notations. The problem was in implementing the $…[?(@name==‘t’)].values anfd the ‘r’ respectively in the two last nodes.

EDITED: It seems like haveing a $ with two dots after it (and perhaps a bracket) shows THREE dots instead!?

So problem solved? Should I provide the fixed version of the workflow - seems I don’t have an option right here?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.