Answered How to convert a JSON string into a JSON object.

Cecil

19+ years progress programming and still learning.
I think I've asked this question before and I think I know the answer.

I need to be able to import a complex JSON string and make make it into a JSON object. The JSON string can be a non-defined pattern because it's is generated from other sources.
 

Cecil

19+ years progress programming and still learning.
Found the answer (sort of):
Code:
USING Progress.Json.ObjectModel.*.

DEFINE VARIABLE myLongchar  AS LONGCHAR NO-UNDO.
DEFINE VARIABLE myParser    AS ObjectModelParser NO-UNDO.
DEFINE VARIABLE JSON        AS JsonObject NO-UNDO.

myLongchar = '~{"url":"www.progresstalk.com"}'.       
myLongchar = CODEPAGE-CONVERT(myLongchar, "UTF-8":U).

myParser = NEW ObjectModelParser().

JSON = CAST(myParser:Parse(myLongchar), JsonObject).

message
    JSON:GETCHARACTER("url")    /** parameter is case sensitive! **/
    view-as alert-box info.
 
delete object myParser. 
delete object JSON.

Just need to figure out how to step through each JsonObject to get a list Property Name(s).
Found IT! The method is GetNames( ).
 
Last edited:
Top