Extension packages / The util package |
The util.JSONObject class provides methods to handle an structured data object following the JSON string syntax.
IMPORT util
{ "cust_num":2735, "cust_name":"McCarlson", "order_ids":[234,3456,24656,34561], "address": { "street":"34, Sunset Bld", "city":"Los Angeles", "state":"CA" } }
A JSONObject object must be created before usage with one of the class methods like util.JSONObject.create().
The JSONObject class provides methods for accessing, adding/replacing or deleting the values by name with the get(), put() and remove() methods.
The get() method can return a simple value, a util.JSONObject or a util.JSONArray object reference.
The put() method can take a simple value, a RECORD, or an ARRAY as parameter.
If the structure of the JSON object is not known at compile time, you can introspect the elements of the object with the getLength(), getType() and name() methods.