public final class JSONObject extends AbstractMap<JSONString,Object>
This is an Object in the JSON language.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
JSONObject()
This creates an empty JSONObject
|
JSONObject(Map<JSONString,?> other)
This creates a JSONObject containing the contents of other.
|
JSONObject(String unparsedString)
Creates a JSONObject from an unparsed CharSequence
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the mappings from this map.
|
static Object |
decode(String c)
Deprecated.
use
ToJavaObjectJSONDecoder instead |
static String |
encode(Object o)
Encodes the object into an unparsed string
TODO: make depreciated somehow.
|
Set<Map.Entry<JSONString,Object>> |
entrySet() |
CharSequence |
getUnparsed()
returns a charsequence containing the unparsed verion of this object
|
static boolean |
isValid(String c)
Deprecated.
use
isValid.jsonObject(java.lang.String) instead |
Object |
put(JSONString key,
Object value)
Associates the specified value with the specified key in this map.
|
int |
size() |
clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, toString, values
public JSONObject()
public JSONObject(Map<JSONString,?> other)
other
- the Map to copy values frompublic JSONObject(String unparsedString) throws NullPointerException, ParseException
unparsedString
- the unparsed CharSequenceParseException
- if unparsedString is impropperly formattedNullPointerException
- if unparsedString is nullpublic CharSequence getUnparsed()
public Set<Map.Entry<JSONString,Object>> entrySet()
entrySet
in interface Map<JSONString,Object>
entrySet
in class AbstractMap<JSONString,Object>
public Object put(JSONString key, Object value)
put
in interface Map<JSONString,Object>
put
in class AbstractMap<JSONString,Object>
key
- the key to associate a value withvalue
- the value to be associatedpublic void clear()
clear
in interface Map<JSONString,Object>
clear
in class AbstractMap<JSONString,Object>
public int size()
size
in interface Map<JSONString,Object>
size
in class AbstractMap<JSONString,Object>
public static Object decode(String c) throws NullPointerException, ClassCastException
ToJavaObjectJSONDecoder
insteadc
- the CharSequence to decodeNullPointerException
- if c is nullClassCastException
- if the string is does not match any associate typespublic static String encode(Object o) throws ClassCastException
o
- the objectClassCastException
- if the object is not one of the following types:
Boolean
Number
CharSequence
Collection
Map
public static boolean isValid(String c)
isValid.jsonObject(java.lang.String)
insteadc
- the string to testJSONObject(String)
can execute without errors
using the specified CharSequence