util.JSONObject.fromFGL()

 

util.JSONObject.fromFGL()creates a new JSON object from a RECORD.

 

Syntax:

 

util.JSONObject.fromFGL(source)

 

Parameters:

 

source

a RECORD variable from that the JSON object is created

 

Usage and examples:

 

util.JSONObject.fromFGL() converts the elements of the RECORD into the name:value pairs of the JSON object.

 

An object newly created by util.JSONObject.fromFGL() must be assigned to a variable of the util.JSONObject data type.

 

example code

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()

 

  CALL fgl_getkey()

END MAIN

 

obtained results

 

For greater details on how fgl data types are converted into JSON strings, refer here.

 

 

Example programs:

CVS server: client.querix.com

CVS repository: /lycia_doc_examples

User: client

Project: auxiliary_features/json

Program: util_JSONObject_fromFGL

 

Related articles:

util.JSONObject.create()

util.JSONObject.parse()