util.JSONObject.fromFGL

Creates a new JSON object from a RECORD.

Syntax

util.JSONObject.fromFGL(
   record record-type )
  RETURNS util.JSONObject
  1. record is the record variable used to create the JSON object.
  2. record-type is a RECORD ... END RECORD type.

Usage

The util.JSONObject.fromFGL() method creates a new JSON object from the RECORD variable passed as parameter.

The new created object must be assigned to a program variable defined with the util.JSONObject type.

The members of the RECORD are converted to name/value pairs in the JSON object.

For more details about FGL to JSON conversion, 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 obj util.JSONObject
    LET cust_rec.cust_num = 345
    LET cust_rec.cust_name = "McMaclum"
    LET cust_rec.order_ids[1] = 4732
    LET cust_rec.order_ids[2] = 9834
    LET cust_rec.order_ids[3] = 2194
    LET obj = util.JSONObject.fromFGL(cust_rec)
    DISPLAY obj.toString()
END MAIN