Skip to main content

Any U2 Basic program utility available to import JSON object into a dynamic array or Name-Value pair? I expect the U2 program to accept a JSON object as an input, and a list of Variable names to parsed from the JSON object. The output could be a name-value pair.



------------------------------
suresh anbil
Owner
OHM Systems Inc
Cincinnati OH US
------------------------------

Any U2 Basic program utility available to import JSON object into a dynamic array or Name-Value pair? I expect the U2 program to accept a JSON object as an input, and a list of Variable names to parsed from the JSON object. The output could be a name-value pair.



------------------------------
suresh anbil
Owner
OHM Systems Inc
Cincinnati OH US
------------------------------

Now that would be very handy.

I could also see a large number of variables requiring consideration.



------------------------------
Shawn Waldie
enterprise application developer
Rocket Forum Shared Account
Los Angeles CA US
------------------------------

Any U2 Basic program utility available to import JSON object into a dynamic array or Name-Value pair? I expect the U2 program to accept a JSON object as an input, and a list of Variable names to parsed from the JSON object. The output could be a name-value pair.



------------------------------
suresh anbil
Owner
OHM Systems Inc
Cincinnati OH US
------------------------------

Suresh,

From my support days, I recall some customers who would use UDO to read in the JSON, convert it to XML, and then create XMAPS to map it to a dynamic array.  If one of them happens to be on the forum, perhaps they will share what they did.

I tend to look to Python as a better way of dealing with a JSON, please see the following:

UOPY Example - Working with JSON | Rocket U2 | UniVerse & UniData (rocketsoftware.com)

Hope that helps



------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
US
------------------------------

Any U2 Basic program utility available to import JSON object into a dynamic array or Name-Value pair? I expect the U2 program to accept a JSON object as an input, and a list of Variable names to parsed from the JSON object. The output could be a name-value pair.



------------------------------
suresh anbil
Owner
OHM Systems Inc
Cincinnati OH US
------------------------------

Hi Suresh, UDO functions allows you to parse a JSON, and then extract values from properties or arrays. We use UDO functions thoroughly in our MV web framework to produce and parse JSON.

  Hope this helps,

  Enrique Murphy



------------------------------
Enrique Ignacio Murphy
Software Engineer
Aleator SRL
Argentina
------------------------------

Hi Suresh, UDO functions allows you to parse a JSON, and then extract values from properties or arrays. We use UDO functions thoroughly in our MV web framework to produce and parse JSON.

  Hope this helps,

  Enrique Murphy



------------------------------
Enrique Ignacio Murphy
Software Engineer
Aleator SRL
Argentina
------------------------------

Thanks. We'll give that a try in a few days, and keep you posted on the progress.



------------------------------
Suresh Anbil
U2 Programmer
OHM Systems Inc
Cincinnati OH US
------------------------------

Hi Suresh, UDO functions allows you to parse a JSON, and then extract values from properties or arrays. We use UDO functions thoroughly in our MV web framework to produce and parse JSON.

  Hope this helps,

  Enrique Murphy



------------------------------
Enrique Ignacio Murphy
Software Engineer
Aleator SRL
Argentina
------------------------------

Hi Enrique,

I am not familiar with UDO functions, would you be able to assist me with this please, examples or documentation please?



------------------------------
Daniel Conradie
Rocket Forum Shared Account
------------------------------

Hi Enrique,

I am not familiar with UDO functions, would you be able to assist me with this please, examples or documentation please?



------------------------------
Daniel Conradie
Rocket Forum Shared Account
------------------------------

Daniel,

This is an old Blog post but it should help.

https://www.rocketsoftware.com/blogs/parse-json-u2-dynamic-objects

Also, the documentation can be found at doc.rocketsoftware.com

UDO is in a few manuals, but I always go to the latest Basic Extensions Manual.



------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
US
------------------------------

Daniel,

This is an old Blog post but it should help.

https://www.rocketsoftware.com/blogs/parse-json-u2-dynamic-objects

Also, the documentation can be found at doc.rocketsoftware.com

UDO is in a few manuals, but I always go to the latest Basic Extensions Manual.



------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
US
------------------------------

thanks very much Mike, will have a look through that all.



------------------------------
Daniel Conradie
Rocket Forum Shared Account
------------------------------

Any U2 Basic program utility available to import JSON object into a dynamic array or Name-Value pair? I expect the U2 program to accept a JSON object as an input, and a list of Variable names to parsed from the JSON object. The output could be a name-value pair.



------------------------------
suresh anbil
Owner
OHM Systems Inc
Cincinnati OH US
------------------------------

Hi ,

I share two subr to handle json clob from basic to extract values. The inside comments are in french but you can translate it easily

IN.JS.XPATH  

Allows you to extract a value in a json by expressing its path such as key.key.key….

key := a property or object name  

key := an array name followed by the item number: key[x]

x := a positive integer

root can be an array [] with values, keypair or object 

Syntax: CALL IN.JS.XPATH(RESULT[out], JSON[in], XPATH[in], ERR[out])

RESULT will be the value ;  if one key of the xpath refer a array without [indice] the complete array is returned with @am/@vm/@sm .. regarding the nest-level of the array
JSON is the json object to search for.
- it can be in string json format
- it can be in UDO format, usefull to request many times on the save udo
XPATH is the path to search:  key.key[x].key   or  [x].key.key  or key[x].key.key.key

ERR is error return
ERR<1> = 0 no error
ERR<2> = 1; the requested xpath does not exist; RESULT contains 'empty'
ERR<1> = 1 error
ERR<2> the error message

see IN.JS.XPATH.SAMPLE attached

IN.JS.XPATH.LIST 

Allows you to list all the xpaths of a json.

Syntax: CALL IN.JS.XPATH.LIST(RESULT[out], ROOT[in], JSON[in])

RESULT: am'ed with each AM in the format: xpath key[x].key.key = value (type)
type := string, number, true, false, null
ROOT is either 'empty' or the word to use to say the first key
ROOT = root → RESULT<x> ⇒ root.key.key…
ROOT = '' → RESULT<x> ⇒ key.key…
JSON: is the json object,
- it can be in string json format
- it can be in UDO format

see IN.JS.XPATH.LIST.SAMPLE attached

i hope this help



------------------------------
Manu Fernandes
------------------------------

Any U2 Basic program utility available to import JSON object into a dynamic array or Name-Value pair? I expect the U2 program to accept a JSON object as an input, and a list of Variable names to parsed from the JSON object. The output could be a name-value pair.



------------------------------
suresh anbil
Owner
OHM Systems Inc
Cincinnati OH US
------------------------------

Here are some of examples of how the UDO functions work.  Might assist in the understanding. 

https://github.com/RocketSoftware/multivalue-lab/tree/master/U2/Demos/UDO/JSON



------------------------------
Greg Livingston
Universe Practice Lead
OUTsurance Insurance
Centurion GA ZA
------------------------------

Any U2 Basic program utility available to import JSON object into a dynamic array or Name-Value pair? I expect the U2 program to accept a JSON object as an input, and a list of Variable names to parsed from the JSON object. The output could be a name-value pair.



------------------------------
suresh anbil
Owner
OHM Systems Inc
Cincinnati OH US
------------------------------

We do this all the time with our Red Leaf web framework.  Based on that project, we have a series of API routines to extract JSON data into name-value pairs.  The problem with JSON (and XML) is that the nesting can go deeper than three levels.  So the API routines allow an X-Path kind of specifier to identify what to extract so anything can be extracted, even if it's deeper than attributes/values/subvalues.



------------------------------
Kevin King
President
Precision Solutions, Inc.
Longmont CO US
------------------------------

We do this all the time with our Red Leaf web framework.  Based on that project, we have a series of API routines to extract JSON data into name-value pairs.  The problem with JSON (and XML) is that the nesting can go deeper than three levels.  So the API routines allow an X-Path kind of specifier to identify what to extract so anything can be extracted, even if it's deeper than attributes/values/subvalues.



------------------------------
Kevin King
President
Precision Solutions, Inc.
Longmont CO US
------------------------------

Hi Kevin,

that sounds good, could you send me samples or anything that i can look at to see if i can use it pls?



------------------------------
Daniel Conradie
Rocket Forum Shared Account
------------------------------

Hi Kevin,

that sounds good, could you send me samples or anything that i can look at to see if i can use it pls?



------------------------------
Daniel Conradie
Rocket Forum Shared Account
------------------------------

Daniel, send me your email address and I'll send you the code and docs.



------------------------------
Kevin King
President
Precision Solutions, Inc.
Longmont CO US
------------------------------

Daniel, send me your email address and I'll send you the code and docs.



------------------------------
Kevin King
President
Precision Solutions, Inc.
Longmont CO US
------------------------------

daniel.conradienz@gmail.com

Thanks very much Kevin



------------------------------
Daniel Conradie
Rocket Forum Shared Account
------------------------------