|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectxv.json.JSONVariant
xv.json.JSONObject
public class JSONObject
A mutable JSON object.
(Note that, at present, you're allowed to insert null keys. A null key is not valid JSON, but at present, I'm too lazy to write all the wrapper code required to catch such a thing. A future version will definitely do that, so don't use null keys. Null values, on the other hand, are permitted.)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Constructor Summary | |
---|---|
JSONObject()
|
Method Summary | |
---|---|
void |
clear()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set<Map.Entry<String,JSONVariant>> |
entrySet()
|
boolean |
equals(Object o)
|
JSONVariant |
get(Object key)
|
JSONArray |
getArray(String property)
Gets the given property as an array. |
boolean |
getBoolean(String property)
|
boolean |
getBoolean(String property,
boolean defaultValue)
|
byte |
getByte(String property)
Gets the given property as a byte. |
byte |
getByte(String property,
byte defaultValue)
Gets the given property as a byte. |
double |
getDouble(String property)
Gets the given property as a double. |
double |
getDouble(String property,
double defaultValue)
Gets the given property as a double. |
float |
getFloat(String property)
Gets the given property as a float. |
float |
getFloat(String property,
float defaultValue)
Gets the given property as a float. |
int |
getInt(String property)
Gets the given property as an integer. |
int |
getInt(String property,
int defaultValue)
Gets the given property as an integer. |
long |
getLong(String property)
Gets the given property as an integer. |
long |
getLong(String property,
long defaultValue)
Gets the given property as an integer. |
Number |
getNumber(String property)
Gets the given property as a number. |
JSONObject |
getObject(String property)
Gets the given property as an object. |
short |
getShort(String property)
Gets the given property as a short. |
short |
getShort(String property,
short defaultValue)
Gets the given property as a short. |
String |
getString(String property)
Gets the given property as a string. |
String |
getType()
Returns "object" . |
int |
hashCode()
|
boolean |
isEmpty()
|
Set<String> |
keySet()
|
JSONVariant |
put(String key,
JSONVariant value)
|
void |
putAll(Map<? extends String,? extends JSONVariant> t)
|
JSONVariant |
remove(Object key)
|
JSONArray |
requireArray(String property)
Gets the given property as an array. |
boolean |
requireBoolean(String property)
Gets the given property as a boolean. |
Number |
requireNumber(String property)
Gets the given property as a number. |
JSONObject |
requireObject(String property)
Gets the given property as an object. |
String |
requireString(String property)
Gets the given property as a string. |
int |
size()
|
Collection<JSONVariant> |
values()
|
Methods inherited from class xv.json.JSONVariant |
---|
toJSON, write |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSONObject()
Method Detail |
---|
public void clear()
clear
in interface Map<String,JSONVariant>
public boolean containsKey(Object key)
containsKey
in interface Map<String,JSONVariant>
public boolean containsValue(Object value)
containsValue
in interface Map<String,JSONVariant>
public Set<Map.Entry<String,JSONVariant>> entrySet()
entrySet
in interface Map<String,JSONVariant>
public boolean equals(Object o)
equals
in interface Map<String,JSONVariant>
equals
in class Object
public JSONVariant get(Object key)
get
in interface Map<String,JSONVariant>
public int hashCode()
hashCode
in interface Map<String,JSONVariant>
hashCode
in class Object
public boolean isEmpty()
isEmpty
in interface Map<String,JSONVariant>
public Set<String> keySet()
keySet
in interface Map<String,JSONVariant>
public JSONObject getObject(String property)
null
.
property
-
public JSONObject requireObject(String property) throws JSONException
JSONException
.
property
- the property to look up
JSONException
- if the property does not exist or is not an objectpublic JSONArray getArray(String property)
null
.
property
-
public JSONArray requireArray(String property) throws JSONException
JSONException
.
property
- the property to look up
JSONException
- if the property does not exist or is not an arraypublic Number getNumber(String property)
null
.
property
-
public Number requireNumber(String property) throws JSONException
null
.
property
- the property to look up
Number
JSONException
- if the property does not exist or is not a numberpublic String getString(String property) throws JSONException
null
.
property
-
JSONException
public String requireString(String property) throws JSONException
property
- the property to look up
JSONException
- if the property does not exist or is not a stringpublic boolean getBoolean(String property)
public boolean getBoolean(String property, boolean defaultValue)
public boolean requireBoolean(String property) throws JSONException
property
- the property to look up
JSONException
- if the property does not exist or is not a booleanpublic byte getByte(String property, byte defaultValue)
property
- defaultValue
- the value to return if the property is not a number
public byte getByte(String property)
null
.
property
-
public short getShort(String property, short defaultValue)
property
- defaultValue
- the value to return if the property is not a number
public short getShort(String property)
property
- defaultValue
- the value to return if the property is not a number
public int getInt(String property, int defaultValue)
property
- defaultValue
- the value to return if the property is not a number
public int getInt(String property)
property
- defaultValue
- the value to return if the property is not a number
public long getLong(String property, long defaultValue)
property
- defaultValue
- the value to return if the property is not a number
public long getLong(String property)
property
- defaultValue
- the value to return if the property is not a number
public float getFloat(String property, float defaultValue)
property
- defaultValue
- the value to return if the property is not a number
public float getFloat(String property)
property
- the property to look up
public double getDouble(String property, double defaultValue)
property
- defaultValue
- the value to return if the property is not a number
public double getDouble(String property)
property
- the property to look up
public JSONVariant put(String key, JSONVariant value)
put
in interface Map<String,JSONVariant>
public void putAll(Map<? extends String,? extends JSONVariant> t)
putAll
in interface Map<String,JSONVariant>
public JSONVariant remove(Object key)
remove
in interface Map<String,JSONVariant>
public int size()
size
in interface Map<String,JSONVariant>
public Collection<JSONVariant> values()
values
in interface Map<String,JSONVariant>
public String getType()
"object"
.
getType
in class JSONVariant
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |