get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JsonArray
, JsonObject
, Number
, String
, or the JsonObject.NULL
object. A JsonObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JsonObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.This class can coerce values to another type when requested.
This class can look up both mandatory and optional values:
getType()
to retrieve a mandatory value. This fails with a {@code JSONException} if the requested name has no valueor if the value cannot be coerced to the requested type. optType()
to retrieve an optional value. This returns a system- or user-supplied default if the requested name has no value or if the value cannot be coerced to the requested type. Warning: this class represents null in two incompatible ways: the standard Java {@code null} reference, and the sentinel value {@link JSONObject#NULL}. In particular, calling {@code put(name, null)} removes thenamed entry from the object but {@code put(name, JSONObject.NULL)} stores anentry whose value is {@code JSONObject.NULL}.
Instances of this class are not thread safe. Although this class is nonfinal, it was not designed for inheritance and should not be subclassed. In particular, self-use by overrideable methods is not specified. See Effective Java Item 17, "Design and Document or inheritance or else prohibit it" for further information.
get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix. Members can be added using one of the add(name, value)
methods. Accepted values are either instances of {@link JsonValue}, strings, primitive numbers, or boolean values. To override values in an object, the set(name, value)
methods can be used. However, not that the add
methods perform better than set
.
Members can be accessed by their name using {@link #get(String)}. A list of all names can be obtained from the method {@link #names()}. This class also supports iterating over the members in document order using an {@link #iterator()} or an enhanced for loop:
for( Member member : jsonObject ) { String name = member.getName(); JsonValue value = member.getValue(); ... }
Note that this class is not thread-safe. If multiple threads access a JsonObject
instance concurrently, while at least one of these threads modifies the contents of this object, access to the instance must be synchronized externally. Failure to do so may lead to an inconsistent state.
This class is not supposed to be extended by clients.
get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix. Members can be added using the add(String, ...)
methods which accept instances of {@link JsonValue}, strings, primitive numbers, and boolean values. To modify certain values of an object, use the set(String, ...)
methods. Please note that the add
methods are faster than set
as they do not search for existing members. On the other hand, the add
methods do not prevent adding multiple members with the same name. Duplicate names are discouraged but not prohibited by JSON.
Members can be accessed by their name using {@link #get(String)}. A list of all names can be obtained from the method {@link #names()}. This class also supports iterating over the members in document order using an {@link #iterator()} or an enhanced for loop:
for( Member member : jsonObject ) { String name = member.getName(); JsonValue value = member.getValue(); ... }
Even though JSON objects are unordered by definition, instances of this class preserve the order of members to allow processing in document order and to guarantee a predictable output.
Note that this class is not thread-safe. If multiple threads access a JsonObject
instance concurrently, while at least one of these threads modifies the contents of this object, access to the instance must be synchronized externally. Failure to do so may lead to an inconsistent state.
This class is not supposed to be extended by clients.
Used by custom factories to map a JSON object.
@ibm-apiget
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JsonArray
, JsonObject
, Number
, String
, or the JsonObject.NULL
object. A JsonObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JsonObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null. The put
methods add or replace values in an object. For example, myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept: ,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.A JsonObject instance can be created from an input source using {@link JsonReader#readObject()}. For example:
JsonReader jsonReader = new JsonReader(...); JsonObject object = jsonReader.readObject(); jsonReader.close();
It can also be built from scratch using a {@link JsonObjectBuilder}. For example 1: An empty JSON object can be built as follows:
JsonObject object = new JsonObjectBuilder().build();
For example 2: The following JSON { "firstName": "John", "lastName": "Smith", "age": 25, "address" : { "streetAddress", "21 2nd Street", "city", "New York", "state", "NY", "postalCode", "10021" }, "phoneNumber": [ { "type": "home", "number": "212 555-1234" }, { "type": "fax", "number": "646 555-4567" } ] }
can be built using : JsonObject value = new JsonObjectBuilder() .add("firstName", "John") .add("lastName", "Smith") .add("age", 25) .add("address", new JsonObjectBuilder() .add("streetAddress", "21 2nd Street") .add("city", "New York") .add("state", "NY") .add("postalCode", "10021")) .add("phoneNumber", new JsonArrayBuilder() .add(new JsonObjectBuilder() .add("type", "home") .add("number", "212 555-1234")) .add(new JsonObjectBuilder() .add("type", "fax") .add("number", "646 555-4567"))) .build();
{@code JsonObject} can be written to JSON as follows: JsonWriter writer = ... JsonObject obj = ...; writer.writeobject(obj);
{@code JsonObject} values can be {@link JsonObject}, {@link JsonArray}, {@link JsonString}, {@link JsonNumber}, {@link JsonValue#TRUE}, {@link JsonValue#FALSE}, {@link JsonValue#NULL}. These values can be accessed using various accessor methods. In the above example 2, "John" can be got using
String firstName = object.getStringValue("firstName");
This map object provides read-only access to the JSON object data, and attempts to modify the map, whether direct or via its collection views, result in an {@code UnsupportedOperationException}. The map object's iteration ordering is based on the order in which name/value pairs are added to the corresponding builder or the order in which name/value pairs appear in the corresponding stream. @author Jitendra Kotamraju
get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.The constructor can convert an external form string into an internal form Java object. The toString() method creates an external form string.
A get() method returns a value if one can be found, and throws an exception if one cannot be found. An opt() method returns a default value instead of throwing an exception, and so is useful for obtaining optional values.
The generic get() and opt() methods return an object, which you can cast or query for type. There are also typed get() and opt() methods that do type checking and type coersion for you.
The texts produced by the toString() methods are very strict. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
;
as well as by ,
0-
(octal) or 0x-
(hex) prefix.#
get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, {@link org.apache.tapestry5.json.JSONArray}, {@link org.apache.tapestry5.json.JSONLiteral}, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you. The put
methods adds values to an object. For example, myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept: ,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you. The put
methods adds values to an object. For example, myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept: ,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names. The internal form is an object having get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name.
The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, {@code string}, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values.
The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace. '
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or {@code null}.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coersion for you. The put
methods adds values to an object. For example, myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON sysntax rules. The constructors are more forgiving in the texts they will accept: ,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
The put
methods add or replace values in an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string {@code}{"JSON": "Hello, World"}{/code}. The texts produced by the {@code}toString{/code} methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you. The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null. The put
methods add or replace values in an object. For example, myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept: ,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0-
(octal) or 0x-
(hex) prefix.get
and opt
methods for accessing the values by name, and put
methods for adding or replacing values by name. The values can be any of these types: Boolean
, JSONArray
, JSONObject
, Number
, String
, or the JSONObject.NULL
object. A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get
and opt
methods, or to convert values into a JSON text using the put
and toString
methods. A get
method returns a value if one can be found, and throws an exception if one cannot be found. An opt
method returns a default value instead of throwing an exception, and so is useful for obtaining optional values. The generic get()
and opt()
methods return an object, which you can cast or query for type. There are also typed get
and opt
methods that do type checking and type coercion for you.
The put
methods adds values to an object. For example,
myString = new JSONObject().put("JSON", "Hello, World!").toString();produces the string
{"JSON": "Hello, World"}
. The texts produced by the toString
methods strictly conform to the JSON syntax rules. The constructors are more forgiving in the texts they will accept:
,
(comma) may appear just before the closing brace.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and if they are not the reserved words true
, false
, or null
.=
or =>
as well as by :
.;
(semicolon) as well as by ,
(comma).0x-
(hex) prefix.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|