util.JSONObject.toFGL

Fills a record variable with the entries contained in the JSON object.

Syntax

util.JSONObject.toFGL(
  recordRef record-type )
  1. recordRef is the variable to be set with values of the JSON string.
    Important:

    The recordRef is a RECORD variable is passed by reference to the method.

  2. record-type is a RECORD ... END RECORD type.

Usage

The toFGL() method fills the RECORD variable passed as parameter with the corresponding values defined in the JSON object.

The destination record must have the same structure as the JSON source data. For more details see JSON support.

Example

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
    DEFINE obj util.JSONObject
    LET js='{ "cust_num":2735, "cust_name":"McCarlson",
              "order_ids":[234,3456,24656,34561] }'
    LET obj = util.JSONObject.parse( js )
    CALL obj.toFGL( cust_rec )
    DISPLAY cust_rec.cust_name
    DISPLAY cust_rec.order_ids[4]
END MAIN