Parse JSON strings into objects and arrays
- Last Updated: March 14, 2022
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
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.ObjectModelParser.
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:
|
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. The JSON parser returns JsonObject or JsonArray as a JsonConstruct which is why CAST() is required.