I am pretty sure it is 2021 (I might have lost a year or 2 during the pandemic), and I am pretty sure that JSON has been adopted and embraced by pretty much everyone in the galaxy as the tool to use to exchange data between different apps. This can be a deal breaker when seeing if Aware is the right fit. In my case, I need to make a lot of google map calls where the result is nestled JSON. objects within objects. The current solution (having many virtual BOs is kludgy at best. I would love to see the following functions added.
SessionObj.attr = NEW_JSON( NULL OR EXISTING JSON)
SET_JSON(SessionObj.attr, long.dot.delimted.path.to.the.key.pair, value)
SessionObj.newAttr = GET_JSON(SessisonObj.attr, path.to.desired.key.par)
If I had this, I could eliminate a lot of NODE JS Rest calls that are only used to parse the JSON results.
How hard would this be to implement?
Thanks
Bruce
Could the next version focus on better JSON Support
-
- Posts: 7526
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Could the next version focus on better JSON Support
You have to explain it slowly, I am afraid.
1) Where are you trying to use JSON? In your REST calls or somewhere else?
2) Why is the current solution kludgy?
3) How are these functions supposed to work - I cannot understand your description. You will need to provide examples
1) Where are you trying to use JSON? In your REST calls or somewhere else?
2) Why is the current solution kludgy?
3) How are these functions supposed to work - I cannot understand your description. You will need to provide examples
Aware IM Support Team
Re: Could the next version focus on better JSON Support
A good example is when I call the googlemaps API to convert an address to a lat / long pair.
When I make the following call: https://maps.googleapis.com/maps/api/ge ... dress=8439 SW 88th CT Ocala FL
I get the following results:
{
"results" : [
{
"address_components" : [
{
"long_name" : "8439",
"short_name" : "8439",
"types" : [ "street_number" ]
},
{
"long_name" : "Southwest 88th Court",
"short_name" : "SW 88th Ct",
"types" : [ "route" ]
},
{
"long_name" : "Ocala",
"short_name" : "Ocala",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Marion County",
"short_name" : "Marion County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Florida",
"short_name" : "FL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "34481",
"short_name" : "34481",
"types" : [ "postal_code" ]
},
{
"long_name" : "8917",
"short_name" : "8917",
"types" : [ "postal_code_suffix" ]
}
],
"formatted_address" : "8439 SW 88th Ct, Ocala, FL 34481, USA",
"geometry" : {
"location" : {
"lat" : 29.0773262,
"lng" : -82.26593099999999
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 29.0786751802915,
"lng" : -82.2645820197085
},
"southwest" : {
"lat" : 29.0759772197085,
"lng" : -82.26727998029151
}
}
},
"place_id" : "EiU4NDM5IFNXIDg4dGggQ3QsIE9jYWxhLCBGTCAzNDQ4MSwgVVNBIhsSGQoUChIJe6EI-xh56IgRgRSos57hFRIQ90E",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
What I need is results[0].geometry.location.lat and results[0].geometry.location.long
This is just ONE of the many calls I make, each with very different JSON results. If I could define an attribute as JSON and load this results into it. Then I could easily access it by a function. Assuming I made a REST call and had the results returned to OBJ.results, then I can update my primative lat / long attributes with a simple function call. i.e. Obj.lat = GET_JSON(obj.results, '[0].geometry.location.lat')
This is a LOT easier than creating multiple virtual tables to hold the JSON return. With your current implementation, it is not easy to see the nestling of the tables.
How about if you embrace JSON as a primitive attribute type? Does this make sense?
Bruce
When I make the following call: https://maps.googleapis.com/maps/api/ge ... dress=8439 SW 88th CT Ocala FL
I get the following results:
{
"results" : [
{
"address_components" : [
{
"long_name" : "8439",
"short_name" : "8439",
"types" : [ "street_number" ]
},
{
"long_name" : "Southwest 88th Court",
"short_name" : "SW 88th Ct",
"types" : [ "route" ]
},
{
"long_name" : "Ocala",
"short_name" : "Ocala",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Marion County",
"short_name" : "Marion County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Florida",
"short_name" : "FL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "34481",
"short_name" : "34481",
"types" : [ "postal_code" ]
},
{
"long_name" : "8917",
"short_name" : "8917",
"types" : [ "postal_code_suffix" ]
}
],
"formatted_address" : "8439 SW 88th Ct, Ocala, FL 34481, USA",
"geometry" : {
"location" : {
"lat" : 29.0773262,
"lng" : -82.26593099999999
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 29.0786751802915,
"lng" : -82.2645820197085
},
"southwest" : {
"lat" : 29.0759772197085,
"lng" : -82.26727998029151
}
}
},
"place_id" : "EiU4NDM5IFNXIDg4dGggQ3QsIE9jYWxhLCBGTCAzNDQ4MSwgVVNBIhsSGQoUChIJe6EI-xh56IgRgRSos57hFRIQ90E",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
What I need is results[0].geometry.location.lat and results[0].geometry.location.long
This is just ONE of the many calls I make, each with very different JSON results. If I could define an attribute as JSON and load this results into it. Then I could easily access it by a function. Assuming I made a REST call and had the results returned to OBJ.results, then I can update my primative lat / long attributes with a simple function call. i.e. Obj.lat = GET_JSON(obj.results, '[0].geometry.location.lat')
This is a LOT easier than creating multiple virtual tables to hold the JSON return. With your current implementation, it is not easy to see the nestling of the tables.
How about if you embrace JSON as a primitive attribute type? Does this make sense?
Bruce
-
- Posts: 2413
- Joined: Mon Jul 02, 2012 12:24 am
- Location: Ulaanbaatar, Mongolia
Re: Could the next version focus on better JSON Support
Nice Idea Bruce.... Love it!
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Re: Could the next version focus on better JSON Support
you guys on drugs?
this is the same thing i was asking about last week
this is the same thing i was asking about last week
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
Package javax.xml.xpath
Vlad
is there a way you can give us access to this?
https://docs.oracle.com/javase/7/docs/a ... mmary.html
or how can we copy this library into our awareIM installation and use it?
Maybe you are already using this to parse XML replies?
is there a way you can give us access to this?
https://docs.oracle.com/javase/7/docs/a ... mmary.html
or how can we copy this library into our awareIM installation and use it?
Maybe you are already using this to parse XML replies?
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: Could the next version focus on better JSON Support
how could we, from a rule, do something like:
bo.value = EXEC_SCRIPT ( sessionvars.theJSON , search_pattern )
ie.
bo.value = EXEC_SCRIPT ( '<short_name>ACME/short_name><type>postal_code</type><geometry><location><lat>32.9137311</lat><lng>-80.1118875</lng>' ,
'<lat>' )
And we could have a JSON script parse the string on the client?
bo.value = EXEC_SCRIPT ( sessionvars.theJSON , search_pattern )
ie.
bo.value = EXEC_SCRIPT ( '<short_name>ACME/short_name><type>postal_code</type><geometry><location><lat>32.9137311</lat><lng>-80.1118875</lng>' ,
'<lat>' )
And we could have a JSON script parse the string on the client?
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
-
- Posts: 7526
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Could the next version focus on better JSON Support
I see.
So the real problem seems to be parsing of JSON and XML replies from REST services. I take it, construction of JSON/XML to call REST services is not a problem.
So you really just need a couple of functions along these lines:
Object.Attribute1 = Parse_JSON (Object.Attribute2, PathToRequiredValue)
Object.Attribute1 = Parse_XML (Object.Attribute2, PathToRequiredValue)
You can easily store the entire reply of the service in some attribute (Aware IM lets you do that) and then just parse the reply and assign values to different attributes.
The syntax of the path to a value is a secondary matter - could be XPath for XML and something else for JSON.
Am I right?
So the real problem seems to be parsing of JSON and XML replies from REST services. I take it, construction of JSON/XML to call REST services is not a problem.
So you really just need a couple of functions along these lines:
Object.Attribute1 = Parse_JSON (Object.Attribute2, PathToRequiredValue)
Object.Attribute1 = Parse_XML (Object.Attribute2, PathToRequiredValue)
You can easily store the entire reply of the service in some attribute (Aware IM lets you do that) and then just parse the reply and assign values to different attributes.
The syntax of the path to a value is a secondary matter - could be XPath for XML and something else for JSON.
Am I right?
Aware IM Support Team
Re: Could the next version focus on better JSON Support
In my opinion, YES - these functions would help a great deal when we don't want to go through the effort of a big complicated BO structure to get a single element back from a service.aware_support wrote: ↑Tue Aug 31, 2021 12:18 am So you really just need a couple of functions along these lines:
Object.Attribute1 = Parse_JSON (Object.Attribute2, PathToRequiredValue)
Object.Attribute1 = Parse_XML (Object.Attribute2, PathToRequiredValue)
Am I right?
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
-
- Posts: 7526
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Could the next version focus on better JSON Support
Makes sense. We'll see what we can do
Aware IM Support Team
-
- Posts: 7526
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Could the next version focus on better JSON Support
We have just released build 2938 which supports PARSE_JSON and PARSE_XML functions
Examples:
Object.Value = PARSE_JSON (Object.JSONAttribute, 'JSON_PATH')
where JSON_Path follows the format described here https://github.com/json-path/JsonPath#getting-started
Object.Value = PARSE_XML (Object.XMLAttribute, 'XPATH')
where XPath follows the format described here https://www.w3.org/TR/1999/REC-xpath-19991116
Examples:
Object.Value = PARSE_JSON (Object.JSONAttribute, 'JSON_PATH')
where JSON_Path follows the format described here https://github.com/json-path/JsonPath#getting-started
Object.Value = PARSE_XML (Object.XMLAttribute, 'XPATH')
where XPath follows the format described here https://www.w3.org/TR/1999/REC-xpath-19991116
Aware IM Support Team