| Modifier and Type | Method and Description |
|---|---|
JSONException |
JSONTokener.syntaxError(java.lang.String message)
Returns an exception containing the given message plus the current
position and the entire input string.
|
static JSONException |
JSON.typeMismatch(java.lang.Object indexOrName,
java.lang.Object actual,
java.lang.String requiredType) |
static JSONException |
JSON.typeMismatch(java.lang.Object actual,
java.lang.String requiredType) |
| Modifier and Type | Method and Description |
|---|---|
JSONObject |
JSONObject.accumulate(java.lang.String name,
java.lang.Object value)
Appends
value to the array already mapped to name. |
JSONObject |
JSONObject.append(java.lang.String name,
java.lang.Object value)
Appends values to the array mapped to
name. |
JSONStringer |
JSONStringer.array()
Begins encoding a new array.
|
private void |
JSONStringer.beforeKey()
Inserts any necessary separators and whitespace before a name.
|
private void |
JSONStringer.beforeValue()
Inserts any necessary separators and whitespace before a literal value,
inline array, or inline object.
|
(package private) static double |
JSON.checkDouble(double d)
Returns the input if it is a JSON-permissible value; throws otherwise.
|
(package private) void |
JSONArray.checkedPut(java.lang.Object value)
Same as
JSONArray.put(boolean), with added validity checks. |
(package private) java.lang.String |
JSONObject.checkName(java.lang.String name) |
(package private) JSONStringer |
JSONStringer.close(JSONStringer.Scope empty,
JSONStringer.Scope nonempty,
java.lang.String closeBracket)
Closes the current scope by appending any necessary whitespace and the
given bracket.
|
JSONStringer |
JSONStringer.endArray()
Ends encoding the current array.
|
JSONStringer |
JSONStringer.endObject()
Ends encoding the current object.
|
java.lang.Object |
JSONArray.get(int index)
Returns the value at
index. |
java.lang.Object |
JSONObject.get(java.lang.String name)
Returns the value mapped by
name, or throws if no such mapping exists. |
boolean |
JSONArray.getBoolean(int index)
Returns the value at
index if it exists and is a boolean or can
be coerced to a boolean. |
boolean |
JSONObject.getBoolean(java.lang.String name)
Returns the value mapped by
name if it exists and is a boolean or
can be coerced to a boolean, or throws otherwise. |
double |
JSONArray.getDouble(int index)
Returns the value at
index if it exists and is a double or can
be coerced to a double. |
double |
JSONObject.getDouble(java.lang.String name)
Returns the value mapped by
name if it exists and is a double or
can be coerced to a double, or throws otherwise. |
int |
JSONArray.getInt(int index)
Returns the value at
index if it exists and is an int or
can be coerced to an int. |
int |
JSONObject.getInt(java.lang.String name)
Returns the value mapped by
name if it exists and is an int or
can be coerced to an int, or throws otherwise. |
JSONArray |
JSONArray.getJSONArray(int index)
Returns the value at
index if it exists and is a JSONArray. |
JSONArray |
JSONObject.getJSONArray(java.lang.String name)
Returns the value mapped by
name if it exists and is a JSONArray, or throws otherwise. |
JSONObject |
JSONArray.getJSONObject(int index)
Returns the value at
index if it exists and is a JSONObject. |
JSONObject |
JSONObject.getJSONObject(java.lang.String name)
Returns the value mapped by
name if it exists and is a JSONObject, or throws otherwise. |
long |
JSONArray.getLong(int index)
Returns the value at
index if it exists and is a long or
can be coerced to a long. |
long |
JSONObject.getLong(java.lang.String name)
Returns the value mapped by
name if it exists and is a long or
can be coerced to a long, or throws otherwise. |
java.lang.String |
JSONArray.getString(int index)
Returns the value at
index if it exists, coercing it if
necessary. |
java.lang.String |
JSONObject.getString(java.lang.String name)
Returns the value mapped by
name if it exists, coercing it if
necessary, or throws if no such mapping exists. |
java.lang.String |
JSONArray.join(java.lang.String separator)
Returns a new string by alternating this array's values with
separator. |
JSONStringer |
JSONStringer.key(java.lang.String name)
Encodes the key (property name) to this stringer.
|
char |
JSONTokener.next(char c)
Returns the next available character if it equals
c. |
java.lang.String |
JSONTokener.next(int length)
Returns the next
length characters of the input. |
char |
JSONTokener.nextClean()
Returns the next character that is not whitespace and does not belong to
a comment.
|
private int |
JSONTokener.nextCleanInternal() |
java.lang.String |
JSONTokener.nextString(char quote)
Returns the string up to but not including
quote, unescaping any
character escape sequences encountered along the way. |
java.lang.Object |
JSONTokener.nextValue()
Returns the next value from the input.
|
static java.lang.String |
JSONObject.numberToString(java.lang.Number number)
Encodes the number as a JSON string.
|
JSONStringer |
JSONStringer.object()
Begins encoding a new object.
|
(package private) JSONStringer |
JSONStringer.open(JSONStringer.Scope empty,
java.lang.String openBracket)
Enters a new scope by appending any necessary whitespace and the given
bracket.
|
private JSONStringer.Scope |
JSONStringer.peek()
Returns the value on the top of the stack.
|
JSONArray |
JSONArray.put(double value)
Appends
value to the end of this array. |
JSONArray |
JSONArray.put(int index,
boolean value)
Sets the value at
index to value, null padding this array
to the required length if necessary. |
JSONArray |
JSONArray.put(int index,
double value)
Sets the value at
index to value, null padding this array
to the required length if necessary. |
JSONArray |
JSONArray.put(int index,
int value)
Sets the value at
index to value, null padding this array
to the required length if necessary. |
JSONArray |
JSONArray.put(int index,
long value)
Sets the value at
index to value, null padding this array
to the required length if necessary. |
JSONArray |
JSONArray.put(int index,
java.lang.Object value)
Sets the value at
index to value, null padding this array
to the required length if necessary. |
JSONObject |
JSONObject.put(java.lang.String name,
boolean value)
Maps
name to value, clobbering any existing name/value
mapping with the same name. |
JSONObject |
JSONObject.put(java.lang.String name,
double value)
Maps
name to value, clobbering any existing name/value
mapping with the same name. |
JSONObject |
JSONObject.put(java.lang.String name,
int value)
Maps
name to value, clobbering any existing name/value
mapping with the same name. |
JSONObject |
JSONObject.put(java.lang.String name,
long value)
Maps
name to value, clobbering any existing name/value
mapping with the same name. |
JSONObject |
JSONObject.put(java.lang.String name,
java.lang.Object value)
Maps
name to value, clobbering any existing name/value
mapping with the same name. |
JSONObject |
JSONObject.putOpt(java.lang.String name,
java.lang.Object value)
Equivalent to
put(name, value) when both parameters are non-null;
does nothing otherwise. |
private JSONArray |
JSONTokener.readArray()
Reads a sequence of values and the trailing closing brace ']' of an
array.
|
private char |
JSONTokener.readEscapeCharacter()
Unescapes the character identified by the character or characters that
immediately follow a backslash.
|
private java.lang.Object |
JSONTokener.readLiteral()
Reads a null, boolean, numeric or unquoted string literal value.
|
private JSONObject |
JSONTokener.readObject()
Reads a sequence of key/value pairs and the trailing closing brace '}' of
an object.
|
JSONArray |
JSONObject.toJSONArray(JSONArray names)
Returns an array with the values corresponding to
names. |
JSONObject |
JSONArray.toJSONObject(JSONArray names)
Returns a new object whose values are the values in this array, and whose
names are the values in
names. |
java.lang.String |
JSONObject.toString(int indentSpaces)
Encodes this object as a human readable JSON string for debugging, such
as:
|
java.lang.String |
JSONArray.toString(int indentSpaces)
Encodes this array as a human readable JSON string for debugging, such
as:
|
static JSONException |
JSON.typeMismatch(java.lang.Object indexOrName,
java.lang.Object actual,
java.lang.String requiredType) |
static JSONException |
JSON.typeMismatch(java.lang.Object actual,
java.lang.String requiredType) |
JSONStringer |
JSONStringer.value(boolean value)
Encodes
value to this stringer. |
JSONStringer |
JSONStringer.value(double value)
Encodes
value to this stringer. |
JSONStringer |
JSONStringer.value(long value)
Encodes
value to this stringer. |
JSONStringer |
JSONStringer.value(java.lang.Object value)
Encodes
value. |
(package private) void |
JSONObject.writeTo(JSONStringer stringer) |
(package private) void |
JSONArray.writeTo(JSONStringer stringer) |
| Constructor and Description |
|---|
JSONArray(JSONTokener readFrom)
Creates a new
JSONArray with values from the next array in the
tokener. |
JSONArray(java.lang.Object array)
Creates a new
JSONArray with values from the given primitive array. |
JSONArray(java.lang.String json)
Creates a new
JSONArray with values from the JSON string. |
JSONObject(JSONObject copyFrom,
java.lang.String[] names)
Creates a new
JSONObject by copying mappings for the listed names
from the given object. |
JSONObject(JSONTokener readFrom)
Creates a new
JSONObject with name/value mappings from the next
object in the tokener. |
JSONObject(java.lang.String json)
Creates a new
JSONObject with name/value mappings from the JSON
string. |