Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error.

PARSE_JSON Help

BLOMASKY

I have a rest call that returns: {"rows returned":3}

I need the # and I am can not figure out how to access it. My last tries were PARSE_JSON(returnObj, '$[rows returned]') but I get a blank

Thanks
Bruce


Jaymer

$.rows returned


Jaymer

In aware, before this, was PARSE_XML (XPath). Never used it, but this is similar.
Once REST in v8 started, it was much needed.
To save us from having to store returned JSON in a physical object, then loop thru those hierarchies, I asked Vlad to implement this - which was probably easy since it's been out there for a while.

Now you just save that returned JSON in a large text field and parse what you need using PARSE_JSON.

There's way more online evaluators now (and examples).
Before messing with aware (by trial and error), I always paste that JSON into an online evaluator to play with search tokens until I get what I want.

The key term to google is "JsonPath Evaluator"
This was the original docs I used when this was introduced in Aware: https://goessner.net/articles/JsonPath/


nhofkes

I also use PARSE_JSON quite a lot in my application. To test the JSON_Path expressions, I built a small test BSV with an object 'Parse_JSON' which has three attributes: InputText, Path, and Result (all plain text fields), and a form that contains those fields. I can then enter any JSON in the InputText field and the JSON_Path expression in the Path field. There is button which calls the process to evaluate the JSON:

Parse_JSON.Result=PARSE_JSON(Parse_JSON.InputText,Parse_JSON.Path)

This gives an immediate response, and it's easy to try and test variations of the expression.

Of course, it's also possible to use another JsonPath evaluator as Jaymer suggested, but with this simple solution I can be sure that it also works in Aware as there is always a (perhaps theoretical) possibility that there is a difference between the implementation in AwareIM and the functionality of the online evaluator.