Example usage for Java org.json JSONObject fields, constructors, methods, implement or subclass
The text is from its open source code.
Object | NULL It is sometimes more convenient and less ambiguous to have a NULL object than to use Java's null value. |
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. |
JSONObject | accumulate(String key, Object value) Accumulate values under a key. |
JSONObject | append(String key, Object value) Append values to the array under a key. |
boolean | equals(Object obj) Indicates whether some other object is "equal to" this one. |
Object | get(String key) Get the value object associated with a key. |
boolean | getBoolean(String key) Get the boolean value associated with a key. |
Class> | getClass() Returns the runtime class of this Object . |
double | getDouble(String key) Get the double value associated with a key. |
int | getInt(String key) Get the int value associated with a key. |
JSONArray | getJSONArray(String key) Get the JSONArray value associated with a key. |
JSONObject | getJSONObject(String key) Get the JSONObject value associated with a key. |
long | getLong(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. |
String | getString(String key) Get the string associated with a key. |
boolean | has(String key) Determine if the JSONObject contains a specific key. |
int | hashCode() Returns a hash code value for the object. |
boolean | isNull(String key) Determine if the value associated with the key is null or if there is no value. |
Iterator | keys() Get an enumeration of the keys of the JSONObject. |
int | length() Get the number of keys stored in the JSONObject. |
JSONArray | names() Produce a JSONArray containing the names of the elements of this JSONObject. |
String | numberToString(Number n) Produce a string from a Number. |
Object | opt(String key) Get an optional value associated with a key. |
boolean | optBoolean(String key) Get an optional boolean associated with a key. |
boolean | optBoolean(String key, boolean defaultValue) Get an optional boolean associated with a key. |
double | optDouble(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. |
double | optDouble(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. |
int | optInt(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. |
int | optInt(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 | optJSONArray(String key) Get an optional JSONArray associated with a key. |
JSONObject | optJSONObject(String key) Get an optional JSONObject associated with a key. |
long | optLong(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. |
long | optLong(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. |
String | optString(String key) Get an optional string associated with a key. |
String | optString(String key, String defaultValue) Get an optional string associated with a key. |
JSONObject | put(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. |
JSONObject | put(String key, boolean value) Put a key/boolean pair in the JSONObject. |
JSONObject | put(String key, double value) Put a key/double pair in the JSONObject. |
JSONObject | put(String key, int value) Put a key/int pair in the JSONObject. |
JSONObject | put(String key, long value) Put a key/long pair in the JSONObject. |
JSONObject | put(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. |
JSONObject | put(String key, Object value) Put a key/value pair in the JSONObject. |
JSONObject | putOpt(String key, Object value) Put a key/value pair in the JSONObject, but only if the key and the value are both non-null. |
String | quote(String string) Produce a string in double quotes with backslash sequences in all the right places. |
Object | remove(String key) Remove a name and its value, if present. |
Iterator | sortedKeys() Get an enumeration of the keys of the JSONObject. |
JSONArray | toJSONArray(JSONArray names) Produce a JSONArray containing the values of the members of this JSONObject. |
String | toString() Make a JSON text of this JSONObject. |
String | toString(int indentFactor) Make a prettyprinted JSON text of this JSONObject. |
String | valueToString(Object value) Make a JSON text of an Object value. |
Writer | write(Writer writer) Write the contents of the JSONObject as JSON text to a writer. |