util.JSONObject.fromFGL

Creates a new JSON object from a RECORD.

Syntax

util.JSONObject.fromFGL(
   source RECORD )
  RETURNING object util.JSONObject
  1. source is the RECORD variable used to create the JSON object.

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 FGL to JSON conversion rules.

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