util.JSON.parse()

util.JSON.parse() parses a JSON string into separate values and fills the corresponding program variable with them.

Syntax

CALL util.JSON.parse(data_string, destination)

Parameters

data_string

a string of JSON formatted data

destination

a RECORD or DYNAMIC ARRAY to be filled with parsed values

destination is passed by reference to the method.

Usage and examples

util.JSON.parse() scans the JSON data string passed as the parameter, separates the pieces of the string that correspond to the destination structure, and fills the destination variable with these separated data pieces (= values).

destination must have the same structure as the JSON data string, i.e. must be a RECORD or DYNAMIC ARRAY.

MAIN
  DEFINE cust_rec RECORD
         cust_num INTEGER,
         cust_name VARCHAR(30),
         order_ids DYNAMIC ARRAY OF INTEGER
         END RECORD
  DEFINE js STRING
LET js='{ "cust_num":2735, "cust_name":"McCarlson", "order_ids":[234,3456,24656,34561] }'
CALL util.JSON.parse(js,cust_rec)
DISPLAY cust_rec
CALL fgl_getkey()
END MAIN

 

 

Contact Us

Privacy Policy

Copyright © 2025 Querix, (UK) Ltd.