How to parse a JSON http response ?

Hello Everybody,

I would like to parse a JSON http response and show only the values I'm interested in. I am trying with a!fromJson function but I am not able to get multiple values in the result body of the call integration to my webAPI.

I would really appreciate getting some help here please.

This is the Json that I receive. I would like to get some of the values from there and be able to filter those I'm interested in. Any ideas?

Gonzalo

  Discussion posts and replies are publicly visible

Parents Reply
  • a!fromJSON will return an "Object" with no specific type. From there, you can access the values via dot notation or via index.

    Assuming local!weatherData is your variable that holds the response.

    with (
       /* ASSUMING RESPONSE BODY IS JSON STRING */
       local!weatherData: a!fromJson(ri!httpResponseBody),
       local!temperature: index(local!weatherData, "main", "temp", null),
       local!pressure: index(local!weatherData, "main", "pressure", null),
       /* RETURNS BOTH TEMPERATURE AND PRESSURE */
       {
         temperature: local!temperature,
         pressure: local!pressure
      }
    )

    I hope this helps.

Children
No Data