Correspondence between a JSON string and an EGL variable for zOS and IBM i
This topic describes the EGL record that corresponds to a JavaScript Object Notation (JSON) string. This topic describes the functions—serviceLib.convertFromJSON() and serviceLib.convertToJSON()—that are used by an EGL developer to convert JSON data to or from a variable either for zOS or IBM i systems. A failure in either function causes a RuntimeException.
JSON and EGL records on zOS:
To create a record part that matches the JSON string, ensure that each field name in the record part exactly matches (in character and case) each corresponding field name in the JSON string, as shown in the following example:
Record MyRecordPart
EmpNo INT;
LastName STRING;
end
EmpNo =10
LastName = "Smith" {“MyRecordPart” : { "EmpNo":10,"LastName":"Smith" }}
Errors found while parsing or generating the JSON string will be issued by COBOL’s JSON PARSE and JSON GENERATE statements.
JSON and EGL records on IBM i:
To create a record part that matches the JSON string, ensure that each field name in the record part exactly matches (in character and case) each corresponding field name in the JSON string, as shown in the following example:
Record MyRecordPart
EmNo INT;
LastName STRING;
end
EmpNo =10
LastName = "Smith" { "EmpNo":10,"LastName":"Smith" }Refer to the Special considerations for JSON support on IBM i for additional information on key considerations while using JSON parse and
generate functions for IBM i.