PARSE_JSON Help

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1491
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

PARSE_JSON Help

Post by 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
Posts: 2539
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: PARSE_JSON Help

Post by Jaymer »

$.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
Posts: 2539
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: PARSE_JSON Help

Post by 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/
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
nhofkes
Posts: 129
Joined: Mon Sep 07, 2020 6:03 am
Location: Netherlands

Re: PARSE_JSON Help

Post by 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.
Niels
(V9.0 build 3272 - MariaDB - Windows)
Post Reply