util.JSONObject.toFGL()fills a RECORD with the elements of the JSON object.
Syntax:
util.JSONObject.toFGL(destination)
Parameters:
destination |
a RECORD variable that will be filled with the elements of the JSON object |
destination is passed by reference to the method.
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.
example code #1 |
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
|
obtained results #1 |
|
example code #2 |
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
|
obtained results #2 |
|
For greater details on how JSON strings are converted into fgl data types, refer here.
Example programs:
CVS server: client.querix.com
CVS repository: /lycia_doc_examples
User: client
Project: auxiliary_features/json
Program: util_JSONObject_toFGL
Related articles: