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
PARSE_JSON Help
Re: PARSE_JSON Help
$.rows returned
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: PARSE_JSON Help
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/
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/
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: PARSE_JSON Help
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:
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.
This gives an immediate response, and it's easy to try and test variations of the expression.Parse_JSON.Result=PARSE_JSON(Parse_JSON.InputText,Parse_JSON.Path)
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.
Niels
(V9.0 build 3272 - MariaDB - Windows)
(V9.0 build 3272 - MariaDB - Windows)