util.JSON.stringify()

util.JSON.stringify() turns a variable into a flat JSON string.

Syntax

CALL util.JSON.stringify(record_var)

Parameters

record_var

a program variable that must be turned into a JSON string

Usage and examples

util.JSON.stringify() takes a variable as a parameter, and turns it into a JSON string based on the general rules and specifications provided by json.org and implemented for Lycia.

MAIN
  DEFINE cust_rec RECORD
         cust_num INTEGER,
         cust_name VARCHAR(30),
         order_ids DYNAMIC ARRAY OF INTEGER
         END RECORD
  DEFINE js STRING
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 js=util.JSON.stringify(cust_rec)
DISPLAY js
CALL fgl_getkey()
END MAIN

For more details on how fgl data types are converted into JSON strings (and vice versa), refer here and here.

If the JSON string cannot be generated, the -8110 error - JSON serialization failed. See the description for more details - is returned to the user.

 

 

Contact Us

Privacy Policy

Copyright © 2025 Querix, (UK) Ltd.