public class ImmutableJSONObject extends MapBasedJSONObject
| Modifier and Type | Class and Description |
|---|---|
static class |
ImmutableJSONObject.Builder |
| Modifier and Type | Field and Description |
|---|---|
protected static ImmutableJSONObject |
EMPTY |
| Modifier and Type | Method and Description |
|---|---|
<A extends JSONArray,O extends JSONObject> |
clone(JSONBuilder<A,O> builder) |
boolean |
equalsMap(java.util.Map<java.lang.String,java.lang.Object> map) |
protected com.google.common.collect.ImmutableMap<java.lang.String,java.lang.Object> |
getMap() |
JSONObject |
put(java.lang.String key,
boolean value)
Put a key/boolean pair in the JSONObject.
|
JSONObject |
put(java.lang.String key,
double value)
Put a key/double pair in the JSONObject.
|
JSONObject |
put(java.lang.String key,
int value)
Put a key/int pair in the JSONObject.
|
JSONObject |
put(java.lang.String key,
long value)
Put a key/long pair in the JSONObject.
|
JSONObject |
put(java.lang.String key,
java.lang.Object value)
Put a key/value pair in the JSONObject.
|
JSONObject |
putOnce(java.lang.String key,
java.lang.Object value)
Put a key/value pair in the JSONObject, but only if the key and the value are both non-null,
and only if there is not already a member with that name.
|
JSONObject |
putOpt(java.lang.String key,
java.lang.Object value)
Put a key/value pair in the JSONObject, but only if the key and the value are both non-null.
|
java.lang.Object |
remove(java.lang.String key)
Remove a name and its value, if present.
|
equals, get, getBoolean, getDouble, getDoubleObj, getInt, getJSONArray, getJSONObject, getLong, getString, has, hashCode, isNull, keys, length, opt, optBoolean, optBoolean, optDouble, optDouble, optDoubleObj, optInt, optInt, optInteger, optInteger, optJSONArray, optJSONObject, optLong, optLong, optString, optString, sortedKeys, toString, toString, toString, toString, writeprotected static final ImmutableJSONObject EMPTY
public boolean equalsMap(java.util.Map<java.lang.String,java.lang.Object> map)
public <A extends JSONArray,O extends JSONObject> O clone(JSONBuilder<A,O> builder) throws JSONException
clone in interface JSONObjectclone in class MapBasedJSONObjectJSONExceptionpublic JSONObject put(java.lang.String key, boolean value) throws JSONException
JSONObjectkey - A key string.value - A boolean which is the value.JSONException - If the key is null.public JSONObject put(java.lang.String key, double value) throws JSONException
JSONObjectkey - 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(java.lang.String key, int value) throws JSONException
JSONObjectkey - A key string.value - An int which is the value.JSONException - If the key is null.public JSONObject put(java.lang.String key, long value) throws JSONException
JSONObjectkey - A key string.value - A long which is the value.JSONException - If the key is null.public JSONObject put(java.lang.String key, java.lang.Object value) throws JSONException
JSONObjectkey - A key string.value - An object which is the value. It should be of one of these types: Boolean, Double,
Integer, JSONArray, JSONObject, Long, String, or the JSONObject.NULL object.JSONException - If the value is non-finite number or if the key is null.public JSONObject putOnce(java.lang.String key, java.lang.Object value) throws JSONException
JSONObjectJSONException - if the key is a duplicatepublic JSONObject putOpt(java.lang.String key, java.lang.Object value) throws JSONException
JSONObjectkey - A key string.value - An object which is the value. It should be of one of these types: Boolean, Double,
Integer, JSONArray, JSONObject, Long, String, or the JSONObject.NULL object.JSONException - If the value is a non-finite number.public java.lang.Object remove(java.lang.String key)
JSONObjectkey - The name to be removed.protected com.google.common.collect.ImmutableMap<java.lang.String,java.lang.Object> getMap()
getMap in class MapBasedJSONObject