Java org.json JSONObject fields, constructors, methods, implement or subclass

Example usage for Java org.json JSONObject fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for org.json JSONObject.

The text is from its open source code.

Subclass

org.json.JSONObject has subclasses.
Click this link to see all its subclasses.

Field

ObjectNULL
It is sometimes more convenient and less ambiguous to have a NULL object than to use Java's null value.

Constructor

JSONObject()
Construct an empty JSONObject.
JSONObject(JSONTokener x)
Construct a JSONObject from a JSONTokener.
JSONObject(Map map)
Construct a JSONObject from a Map.
JSONObject(Object bean)
Construct a JSONObject from an Object using bean getters.
JSONObject(String source)
Construct a JSONObject from a source JSON text string.

Method

JSONObjectaccumulate(String key, Object value)
Accumulate values under a key.
JSONObjectappend(String key, Object value)
Append values to the array under a key.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
Objectget(String key)
Get the value object associated with a key.
booleangetBoolean(String key)
Get the boolean value associated with a key.
ClassgetClass()
Returns the runtime class of this Object .
doublegetDouble(String key)
Get the double value associated with a key.
intgetInt(String key)
Get the int value associated with a key.
JSONArraygetJSONArray(String key)
Get the JSONArray value associated with a key.
JSONObjectgetJSONObject(String key)
Get the JSONObject value associated with a key.
longgetLong(String key)
Get the long value associated with a key.
String[]getNames(JSONObject jo)
Get an array of field names from a JSONObject.
String[]getNames(Object object)
Get an array of field names from an Object.
StringgetString(String key)
Get the string associated with a key.
booleanhas(String key)
Determine if the JSONObject contains a specific key.
inthashCode()
Returns a hash code value for the object.
booleanisNull(String key)
Determine if the value associated with the key is null or if there is no value.
Iteratorkeys()
Get an enumeration of the keys of the JSONObject.
intlength()
Get the number of keys stored in the JSONObject.
JSONArraynames()
Produce a JSONArray containing the names of the elements of this JSONObject.
StringnumberToString(Number n)
Produce a string from a Number.
Objectopt(String key)
Get an optional value associated with a key.
booleanoptBoolean(String key)
Get an optional boolean associated with a key.
booleanoptBoolean(String key, boolean defaultValue)
Get an optional boolean associated with a key.
doubleoptDouble(String key)
Get an optional double associated with a key, or NaN if there is no such key or if its value is not a number.
doubleoptDouble(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.
intoptInt(String key)
Get an optional int value associated with a key, or zero if there is no such key or if the value is not a number.
intoptInt(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.
JSONArrayoptJSONArray(String key)
Get an optional JSONArray associated with a key.
JSONObjectoptJSONObject(String key)
Get an optional JSONObject associated with a key.
longoptLong(String key)
Get an optional long value associated with a key, or zero if there is no such key or if the value is not a number.
longoptLong(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.
StringoptString(String key)
Get an optional string associated with a key.
StringoptString(String key, String defaultValue)
Get an optional string associated with a key.
JSONObjectput(String key, Collection value)
Put a key/value pair in the JSONObject, where the value will be a JSONArray which is produced from a Collection.
JSONObjectput(String key, boolean value)
Put a key/boolean pair in the JSONObject.
JSONObjectput(String key, double value)
Put a key/double pair in the JSONObject.
JSONObjectput(String key, int value)
Put a key/int pair in the JSONObject.
JSONObjectput(String key, long value)
Put a key/long pair in the JSONObject.
JSONObjectput(String key, Map value)
Put a key/value pair in the JSONObject, where the value will be a JSONObject which is produced from a Map.
JSONObjectput(String key, Object value)
Put a key/value pair in the JSONObject.
JSONObjectputOpt(String key, Object value)
Put a key/value pair in the JSONObject, but only if the key and the value are both non-null.
Stringquote(String string)
Produce a string in double quotes with backslash sequences in all the right places.
Objectremove(String key)
Remove a name and its value, if present.
IteratorsortedKeys()
Get an enumeration of the keys of the JSONObject.
JSONArraytoJSONArray(JSONArray names)
Produce a JSONArray containing the values of the members of this JSONObject.
StringtoString()
Make a JSON text of this JSONObject.
StringtoString(int indentFactor)
Make a prettyprinted JSON text of this JSONObject.
StringvalueToString(Object value)
Make a JSON text of an Object value.
Writerwrite(Writer writer)
Write the contents of the JSONObject as JSON text to a writer.