util.JSONObject.toFGL() fills a RECORD with the elements of the JSON object.
Syntax
CALL util.JSONObject.toFGL(destination)
Parameters
destination |
a RECORD variable that will be filled with the elements of the JSON object |
Usage and examples
util.JSONObject.fromFGL() populates the RECORD variable passed as a parameter with the values included in the JSON object.
destination record must have the same structure as the source JSON object.
MAIN
DEFINE cust_rec
RECORD
cust_num INTEGER,
cust_name VARCHAR(30),
order_ids DYNAMIC ARRAY OF INTEGER
END RECORD
DEFINE js STRING
DEFINE json_obj util.JSONObject
LET js='{"cust_num":35, "cust_name":"McCarlson", "order_ids":[234, 3456, 24656, 34561]}'
LET json_obj=util.JSONObject.parse(js)
CALL json_obj.toFGL(cust_rec)
DISPLAY util.JSON.format(js)
CALL fgl_getkey()
END MAIN
MAIN
DEFINE cust_rec RECORD
cust_num INTEGER,
cust_name VARCHAR(30),
order_ids DYNAMIC ARRAY OF INTEGER
END RECORD
DEFINE js STRING
DEFINE json_obj util.JSONObject
LET js='{"cust_num":35, "cust_name":"McCarlson",
"order_ids":[234,3456,24656,34561]}'
LET json_obj
=util.JSONObject.parse(js)
CALL json_obj.toFGL(cust_rec)
DISPLAY "cust_name = ",cust_rec.cust_name
DISPLAY "order_ids = ",cust_rec.order_ids
CALL fgl_getkey()
END MAIN
More details on how JSON strings are converted into fgl data types are here.