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