JSONObject
java.lang.String
format(int indentFactor)
Make a prettyprinted JSON text of this JSONObject.
java.lang.Object
get(java.lang.String key)
Get the value object associated with a key.
boolean
getBoolean(java.lang.String key)
Get the boolean value associated with a key.
boolean
getBoolean(java.lang.String key,
boolean defaultValue)
Get an optional boolean associated with a key.
double
getDouble(java.lang.String key)
Get the double value associated with a key.
double
getDouble(java.lang.String key,
double defaultValue)
Get an optional double associated with a key, or the defaultValue if there is no such key or if its value is not a number.
float
getFloat(java.lang.String key)
float
getFloat(java.lang.String key,
float defaultValue)
int
getInt(java.lang.String key)
Gets the int value associated with a key
int
getInt(java.lang.String key,
int defaultValue)
Get an optional int value associated with a key, or the default if there is no such key or if the value is not a number.
JSONArray
getJSONArray(java.lang.String key)
Get the JSONArray value associated with a key.
JSONObject
getJSONObject(java.lang.String key)
Get the JSONObject value associated with a key.
long
getLong(java.lang.String key)
Get the long value associated with a key.
long
getLong(java.lang.String key,
long defaultValue)
Get an optional long value associated with a key, or the default if there is no such key or if the value is not a number.
java.lang.String
getString(java.lang.String key)
Gets the String associated with a key
java.lang.String
getString(java.lang.String key,
java.lang.String defaultValue)
Get an optional string associated with a key.
boolean
hasKey(java.lang.String key)
Determine if the JSONObject contains a specific key.
boolean
isNull(java.lang.String key)
Determine if the value associated with the key is null or if there is no value.
java.util.Iterator
keyIterator()
Get an enumeration of the keys of the JSONObject.
java.util.Set
keys()
Get a set of keys of the JSONObject.
static JSONObject
parse(java.lang.String source)
Construct a JSONObject from a source JSON text string.
JSONObject
put(java.lang.String key,
java.lang.Object value)
Put a key/value pair in the JSONObject.
static java.lang.String
quote(java.lang.String string)
Produce a string in double quotes with backslash sequences in all the right places.
static java.io.Writer
quote(java.lang.String string,
java.io.Writer w)
java.lang.Object
remove(java.lang.String key)
Remove a name and its value, if present.
boolean
save(java.io.File file,
java.lang.String options)
JSONObject
setBoolean(java.lang.String key,
boolean value)
Put a key/boolean pair in the JSONObject.
JSONObject
setDouble(java.lang.String key,
double value)
Put a key/double pair in the JSONObject.
JSONObject
setFloat(java.lang.String key,
float value)
JSONObject
setInt(java.lang.String key,
int value)
Put a key/int pair in the JSONObject.
JSONObject
setJSONArray(java.lang.String key,
JSONArray value)
JSONObject
setJSONObject(java.lang.String key,
JSONObject value)
JSONObject
setLong(java.lang.String key,
long value)
Put a key/long pair in the JSONObject.
JSONObject
setString(java.lang.String key,
java.lang.String value)
int
size()
Get the number of keys stored in the JSONObject.
java.lang.String
toString()
Return the JSON data formatted with two spaces for indents.
boolean
write(java.io.PrintWriter output)
boolean
write(java.io.PrintWriter output,
java.lang.String options)