The util.JSON class / util.JSON methods |
Parses a JSON string and fills program variables with the values.
util.JSON.parse( source STRING, destination { RECORD | DYNAMIC ARRAY } )
The util.JSON.parse() class method scans the JSON source string passed as parameter and fills the destination variable members by name.
The destination variable should have the same structure as the JSON source data, it can be a RECORD or a DYNAMIC ARRAY.
See JSON to Genero BDL 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