util.JSONObject class is used to modify and manipulate structured data objects following the JSON string syntax.
JSON object is an unordered collection of name:value pairs. JSON objects are enclosed in braces - { to begin the object and } to end it. Every name is followed by : (colon) and is separated from another one by , (comma):
{
"cust_num":2735,
"cust_name":"McCarlson",
"order_ids":[234,3456,24656,34561],
"address": {
"street":"34, Sunset Bld",
"city":"Los Angeles",
"state":"CA"
}
}
JSON objects are created by the util.JSONObject.create() method.
Once created, JSON objects can be studied and manipulated by util.JSONObject methods summarized in the table below.
method |
description and examples |
creates a new JSON object
|
|
creates a new JSON object from a RECORD
|
|
parses a JSON string into a new JSON object
|
|
returns a value that corresponds to the specified entry name
|
|
returns the number of the name:value pairs included in the specified JSON object
|
|
returns the type of the element of the specified JSON object
|
|
checks whether the JSON object includes the element with the specified name
|
|
returns the name of the name:value pair by its index
|
|
adds a name:value pair to the specified JSON object
|
|
removes the specified element from the JSON object
|
|
fills a RECORD with the elements of the JSON object
|
|
produces a JSON string from the values included into the JSON object
|