|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> java.util.HashMap org.apache.wink.json4j.JSONObject org.apache.wink.json4j.OrderedJSONObject
public class OrderedJSONObject
Extension of the basic JSONObject. This class allows control of the serialization order of attributes.
The order in which items are put into the instance controls the order in which they are serialized out. For example, the
last item put is the last item serialized.
JSON-able values are: null, and instances of String, Boolean, Number, JSONObject and JSONArray.
Instances of this class are not thread-safe.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Field Summary |
---|
Fields inherited from class org.apache.wink.json4j.JSONObject |
---|
NULL |
Constructor Summary | |
---|---|
OrderedJSONObject()
Create a new instance of this class. |
|
OrderedJSONObject(InputStream is)
Create a new instance of this class from the data provided from the input stream. |
|
OrderedJSONObject(InputStream is,
boolean strict)
Create a new instance of this class from the data provided from the input stream. |
|
OrderedJSONObject(Map map)
Create a new instance of this class using the contents of the provided map. |
|
OrderedJSONObject(Reader rdr)
Create a new instance of this class from the data provided from the reader. |
|
OrderedJSONObject(Reader rdr,
boolean strict)
Create a new instance of this class from the data provided from the reader. |
|
OrderedJSONObject(String str)
Create a new instance of this class from the provided JSON object string. |
|
OrderedJSONObject(String str,
boolean strict)
Create a new instance of this class from the provided JSON object string. |
Method Summary | |
---|---|
void |
clear()
(non-Javadoc) |
Object |
clone()
Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned. |
Iterator |
getOrder()
Method to obtain the order in which the items will be serialized. |
Object |
put(Object key,
Object value)
Method to put a JSON'able object into the instance. |
Object |
remove(Object key)
Method to remove an entry from the OrderedJSONObject instance. |
Methods inherited from class org.apache.wink.json4j.JSONObject |
---|
append, get, getBoolean, getDouble, getInt, getJSONArray, getJSONObject, getLong, getNames, getShort, getString, has, isNull, isValidObject, isValidType, keys, length, names, opt, optBoolean, optBoolean, optDouble, optDouble, optInt, optInt, optJSONArray, optJSONArray, optJSONObject, optJSONObject, optLong, optLong, optShort, optShort, optString, optString, put, put, put, put, put, put, put, put, put, put, put, put, put, putOnce, putOpt, sortedKeys, toJSONArray, toString, toString, toString, write, write, write, write, write, write, write, write, write |
Methods inherited from class java.util.HashMap |
---|
containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Constructor Detail |
---|
public OrderedJSONObject()
public OrderedJSONObject(String str) throws JSONException
str
- The String of JSON to parse
JSONException
- Thrown when the string passed is null, or malformed JSON..public OrderedJSONObject(String str, boolean strict) throws JSONException
str
- The String of JSON to parsestrict
- Boolean flag indicating if strict mode should be used. Strict mode means comments and unquoted strings are not allowed.
JSONException
- Thrown when the string passed is null, or malformed JSON..public OrderedJSONObject(Reader rdr) throws JSONException
rdr
- The reader from which to read the JSON to parse
JSONException
- Thrown when the string passed is null, or malformed JSON..public OrderedJSONObject(Reader rdr, boolean strict) throws JSONException
rdr
- The reader from which to read the JSON to parsestrict
- Boolean flag indicating if strict mode should be used. Strict mode means comments and unquoted strings are not allowed.
JSONException
- Thrown when the string passed is null, or malformed JSON..public OrderedJSONObject(InputStream is) throws JSONException
is
- The InputStream from which to read the JSON to parse
JSONException
- Thrown when the string passed is null, or malformed JSON..public OrderedJSONObject(InputStream is, boolean strict) throws JSONException
is
- The InputStream from which to read the JSON to parsestrict
- Boolean flag indicating if strict mode should be used. Strict mode means comments and unquoted strings are not allowed.
JSONException
- Thrown when the string passed is null, or malformed JSON..public OrderedJSONObject(Map map) throws JSONException
map
- The map of key/value pairs to insert into this JSON object
JSONException
- Thrown when contents in the map cannot be made JSONable.
NullPointerException
- Thrown if the map is null, or a key in the map is null..Method Detail |
---|
public Object put(Object key, Object value)
put
in interface Map
put
in class JSONObject
HashMap.put(java.lang.Object, java.lang.Object)
public Object remove(Object key)
remove
in interface Map
remove
in class HashMap
HashMap.remove(java.lang.Object)
public void clear()
clear
in interface Map
clear
in class HashMap
HashMap.clear()
public Object clone()
clone
in class HashMap
public Iterator getOrder()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |