| The JSON class / util.JSON methods | |
Parses a JSON string and fills program variables with the values.
util.JSON.parse( source STRING, destination RECORD )
The util.JSON.parse() class method scans the JSON source string passed as parameter and fills the RECORD members by name.
The destination variable should have the same structure as the JSON source data. See JSON to FGL conversion rules for details on how the destination variable is populated when the structures are not identical.
IMPORT util
MAIN
DEFINE cust_rec RECORD
cust_num INTEGER,
cust_name VARCHAR(30),
order_ids DYNAMIC ARRAY OF INTEGER
END RECORD
DEFINE js STRING
LET js='{ "cust_num":2735, "cust_name":"McCarlson",
"order_ids":[234,3456,24656,34561] }'
CALL util.JSON.parse( js, cust_rec )
DISPLAY cust_rec.cust_name
DISPLAY cust_rec.order_ids[4]
END MAIN