JSON help

Again I’m stuck parsing a JSON (displayed below). Any path I try, results in an error. The result I’m trying to achieve is result 1 or 2.

Bonus: it would be very nice if I wouldn’t have to enter the date in the path, but rather result number 1 or 2. So I can simply get the data each morning, and now result 1 is today, and result 2 is tomorrow.

Thank you for your help!

{
  "result": {
    "2023-10-08": 593,
    "2023-10-09": 319
  },
  "message": {
    "code": 0,
    "type": "success",
    "text": "",
    "pid": "iH4eaaaa",
    "info": {
      "latitude": 51.0000,
      "longitude": 5.0000,
      "distance": 0,
      "place": "<knip>, Netherlands",
      "timezone": "Europe/Amsterdam",
      "time": "2023-10-08T00:02:51+02:00",
      "time_utc": "2023-10-07T22:02:51+00:00"
    },
    "ratelimit": {
      "period": 3600,
      "limit": 12,
      "remaining": 11
    }
  }
}

JSONpath $.result.* should return a list of the values:

[
  593,
  319
]

Then you can continue to get either the first or second value with $.0 or $.1.

To my understanding, there is no direct path to get the value, but as above, it is a two step thing.

Somwith advanced flows, you need to JSON parser cards.

Thank you for your reply. When adding the THEN-card with (translated from Dutch):

"Read < answer > as JSON and select pad $.result.* as text-tag

Results in error:

Lexical error on line 1. Unrecognized text.
$. $.result.*
–^

Any suggestions?

You probably shouldn’t use this trailing .* after ‘result’ I guess.
I use this (it returns the contents of ‘liveweer’)

Unfortunately still the same error:

Hmmmm, when I feed your JSON to the parse card, it works. I always compare the original http get result as well when things aren’t going as expected.



Oh, and I learned something new
The path $.result.* returns the values only, omitting the dates :wink: @OH2TH was totally right

Screenshot from 2023-10-09 22-13-45

1 Like

Then I’m certain I’m doing something wrong. I’ve copied all your cards @Peter_Kawa, but I still get the same error.

Are you sure there’s no hidden leading / trailing whitespace, in the $.result… line?

Thank you… :see_no_evil:

1 Like