The ABL JSON object model provides various classes to complete the parsing and generating of a tree of constructs that represent JSON objects and arrays. The two parser classes which help parsing of JSON strings are Progress.Json.JsonParser and Progress.Json.ObjectModel.JsonModelParser.
JsonParser is an abstract class that contains properties common to JSON parsers supported by ABL.
The Parse( ) method from the ObjectModelParser class is used to identify the source of the JSON string and parses the string. The value the method returns is either a Progress.Json.ObjectModel.JsonObject or a Progress.Json.ObjectModel.JsonArray.
The ParseFile( ) method from the ObjectModelParser class parses the JSON from the specified file. The value the method returns is either a Progress.Json.ObjectModel.JsonObject or a Progress.Json.ObjectModel.JsonArray.
The following example shows the reuse of a parser:
DEFINE VARIABLE myLongchar AS LONGCHAR NO-UNDO.
DEFINE VARIABLE myParser AS ObjectModelParser NO-UNDO.
DEFINE VARIABLE Request AS JsonConstruct NO-UNDO.
DEFINE VARIABLE settings AS JsonObject NO-UNDO.
. . .
myParser = NEW ObjectModelParser().
settings = CAST(myParser:Parse(myLongchar), JsonObject).
Request = myParser:Parse(&WEBSTREAM).
In the example above, the AVM parses a LONGCHAR to initialize some settings for the procedure, and then reads and parses from the WebSpeed input stream.