| The util.JSONObject class / util.JSONObject methods | |
Sets a name-value pair in the JSON object.
util.JSONObject.put( name STRING, value value-type )
The put() method adds a name-value pair to the JSON object.
The first parameter is the name of the element. The second parameter can be a simple string or numeric value, or a complex variable defined as RECORD or DYNAMIC ARRAY.
If the element exists, the existing value is replaced.
IMPORT util
MAIN
DEFINE obj util.JSONObject
DEFINE rec RECORD
id INTEGER,
name STRING
END RECORD
DEFINE arr DYNAMIC ARRAY OF INTEGER
LET obj = util.JSONObject.create()
CALL obj.put("simple", 234)
LET rec.id = 234
LET rec.name = "Barton"
CALL obj.put("record", rec)
LET arr[1] = 234
LET arr[2] = 2837
CALL obj.put("array", arr)
DISPLAY obj.toString()
END MAIN