public class JSONObject extends HashMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
JSONObject() |
JSONObject(Map m) |
JSONObject(String jsonStr) |
| Modifier and Type | Method and Description |
|---|---|
JSONObject |
append(String key,
Object value)
Append values to the array under a key.
|
static String[] |
getNames(JSONObject json) |
int |
length() |
static String |
numberToString(Number n)
Produce a string from a Number.
|
Object |
opt(String e) |
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) |
static String |
quote(String string)
Produce a string in double quotes with backslash sequences in all the
right places.
|
String |
toString() |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesequals, hashCodepublic JSONObject()
public JSONObject(String jsonStr) throws JSONException
JSONExceptionpublic JSONObject(Map m)
public int length()
public static String[] getNames(JSONObject json)
public String toString()
toString in class AbstractMappublic JSONObject put(String key, Object value) throws JSONException
JSONExceptionpublic JSONObject put(String key, boolean value) throws JSONException
key - A key string.value - A boolean which is the value.JSONException - If the key is null.public JSONObject put(String key, double value) throws JSONException
key - A key string.value - A double which is the value.JSONException - If the key is null or if the number is invalid.public JSONObject put(String key, int value) throws JSONException
key - A key string.value - An int which is the value.JSONException - If the key is null.public JSONObject put(String key, long value) throws JSONException
key - A key string.value - A long which is the value.JSONException - If the key is null.public JSONObject put(String key, Map value) throws JSONException
key - A key string.value - A Map value.JSONException - If o is a non-finite number.public JSONObject append(String key, Object value) throws JSONException
key - A key string.value - An object to be accumulated under the key.JSONException - If the key is null or if the current value
associated with the key is not a JSONArray.public static String numberToString(Number n) throws JSONException
n - A NumberJSONException - If n is a non-finite number.public static String quote(String string)
string - A StringCopyright © 2017. All rights reserved.