Migration Guide : E. Features Introduced in OpenROAD 6.2 : New Features : JSON Classes Added
 
Share this page          
JSON Classes Added
Eight new classes were added to enable OpenROAD to interact with JSON objects:
JsonArray
JsonBoolean
JsonHandler
JsonNull
JsonNumber
JsonObject
JsonString
JsonValue
The JsonHandler attribute was added to the SessionObject class, and the JsonRpcRequest method was added to the RemoteServer class and its documentation updated.
For complete information about these classes, their attributes, and methods, see the Language Reference Guide.
The environment variable II_W4GL_JSON_CONFIG specifies the full location for the JSON-RPC configuration directory used by the OpenROAD Server. For more information, see “Environment Variables” in the Workbench User Guide.
JsonArray Class
The JsonArray class represents an array in JSON. It has the following attribute:
Items
Data Type: array of JsonValue
4GL Access: RW
Specifies a bag containing the rows (JSON values) in the JSON array.
JsonBoolean Class
This class represents a true or false value in JSON. It has the following attribute:
Value
Data Type: integer
4GL Access: RW
Specifies the boolean value.
JsonHandler Class
The JsonHandler class provides methods for parsing and writing JSON documents (from or into a file or StringObject) and to do conversions between JsonValue (subclass) objects and OpenROAD objects and scalars. It has the following attributes:
AlwaysAddClassname
Data Type: integer
4GL Access: RW
Defines whether to add a "classname" member for any object and a "row_class" member for any ArrayObject when converting OpenROAD objects into JSON.
If set to FALSE (default), these members are only added, if the object referenced is different from their defined type (i.e. if it references a subclass object/array).
IgnoreUnknownAttributes
Data Type: integer
4GL Access: RW
Defines if unknown attributes should be ignored (with WARNING message generated) when converting a JsonObject into an OpenROAD object. Default: FALSE
MaxNestingLevel
Data Type: integer
4GL Access: RW
Defines the maximum nesting level for circular or multiple references when converting OpenROAD objects into JSON.
If set to 0 (default), the additional "$id" and "$ref" meta attributes are used in JSON instead (one object has "$id" attribute, other referencing objects have the "$ref" attribute with the same value).
Errortext
Data Type: varchar(2000)
4GL Access: RO
Contains the Errortext of the last method invocation.
The JsonHandler class has the following methods:
JsonObject2Object
Converts a JsonObject into an OpenROAD object.
JsonRpcRequest
Executes a JSON-RPC 2.0 (jsonrpc) request (or batch/array of requests) given as a StringObject. It returns a StringObject containing the response (NULL for a "Notification" request).
NewJsonValue
Creates a new JsonValue subclass object for a given value (scalar or object).
Object2JsonValue
Converts an OpenROAD object into a JsonValue (JsonObject or JsonNull).
Parse
Parses a StringObject containing JSON and returns a JsonValue subclass object representing the JSON.
ParseFile
Parses a file containing JSON and returns a JsonValue subclass object representing the JSON.
SetSerializableClassAttributes
Sets the serializable attributes for a class.
Write
Writes the JSON for JsonValue subclass object into a StringObject.
WriteFile
Writes the JSON for JsonValue subclass object into a file.
JsonNull Class
The JsonNull class represents a null value in JSON. It has no attributes or methods.
JsonNumber Class
The JsonNumber class represents a number in JSON. It has the following attribute:
TextValue
Data Type: varchar(50)
4GL Access: RW
The text representation of the numeric value. The decimal character is always “.” (a period), independent of II_DECIMAL.
The JsonNumber class has the following methods:
GetValue
Gets the value into a numeric byref variable.
SetValue
Sets the value from a numeric variable.
JsonObject Class
The JsonObject class represents an object in JSON. It has no attributes but has the following methods:
AddMember
Adds a member (name/value pair) to the JsonObject.
Get Member
Returns the value for the member with a given name.
GetMemberNames
Returns an array containing all member names (StringObject).
NewMember
Creates a JsonValue for the given value and adds a member to the JsonObject. The type of JsonValue created depends on the value provided. Returns the new JsonValue created.
RemoveMember
Removes a member from the JsonObject.
JsonString Class
The JsonString class represents a string in JSON. It has the following attribute:
Value
Data Type: StringObject
4GL Access: RW
The string value.
JsonValue Class
The JsonValue class is a superclass for other JSON value classes. It has no attributes or methods.