Package org.zkoss.json
Class JSONObject
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<java.lang.Object,java.lang.Object>
-
- org.zkoss.json.JSONObject
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.Object,java.lang.Object>
,JSONAware
public class JSONObject extends java.util.LinkedHashMap<java.lang.Object,java.lang.Object> implements java.util.Map<java.lang.Object,java.lang.Object>, JSONAware
A JSON object. Key value pairs are in the order of adding. JSONObject supports java.util.Map interface.- Author:
- FangYidong<fangyidong@yahoo.com.cn>
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JSONObject()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
toJSONString()
Encodes this object to a JSON string.static java.lang.String
toJSONString(java.util.Map map)
Convert (aka., encode) a map to JSON text.java.lang.String
toString()
Encodes this object to a JSON string.static java.lang.String
toString(java.lang.String key, java.lang.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
-
-
-
-
Method Detail
-
toJSONString
public static java.lang.String toJSONString(java.util.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 java.lang.String toJSONString()
Encodes this object to a JSON string. It is the same astoString()
.- Specified by:
toJSONString
in interfaceJSONAware
- Returns:
- JSON text
-
toString
public java.lang.String toString()
Encodes this object to a JSON string. It is the same astoJSONString()
.- Overrides:
toString
in classjava.util.AbstractMap<java.lang.Object,java.lang.Object>
-
toString
public static java.lang.String toString(java.lang.String key, java.lang.Object value)
-
-