Package io.keikai.json
Class JSONObject<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<K,V>
-
- io.keikai.json.JSONObject<K,V>
-
- All Implemented Interfaces:
JSONAware,Serializable,Cloneable,Map<K,V>
public class JSONObject<K,V> extends LinkedHashMap<K,V> implements Map<K,V>, JSONAware
A JSON object. Key value pairs are in the order of adding. JSONObject supports java.util.Map interface.- Author:
- FangYidong
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description JSONObject()JSONObject(int initialCapacity)JSONObject(int initialCapacity, float loadFactor)JSONObject(int initialCapacity, float loadFactor, boolean accessOrder)JSONObject(Map<? extends K,? extends V> m)JSONObject(K key, V value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringtoJSONString()Encodes this object to a JSON string.static StringtoJSONString(Map map)Convert (aka., encode) a map to JSON text.StringtoString()Encodes this object to a JSON string.static StringtoString(String key, Object value)-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
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
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
toJSONString
public static String toJSONString(Map map)
Convert (aka., encode) a map to JSON text. The result is a JSON object. If this map is also a JSONAware, JSONAware specific behaviors will be omitted at this top level.- Parameters:
map-- Returns:
- JSON text, or "null" if map is null.
- See Also:
JSONValue.toJSONString(Object)
-
toJSONString
public String toJSONString()
Encodes this object to a JSON string. It is the same astoString().- Specified by:
toJSONStringin interfaceJSONAware- Returns:
- JSON text
-
toString
public String toString()
Encodes this object to a JSON string. It is the same astoJSONString().- Overrides:
toStringin classAbstractMap<K,V>
-
-