Class JSONObject
java.lang.Object
java.util.AbstractMap
java.util.HashMap
org.json.simple.JSONObject
- All Implemented Interfaces:
Serializable, Cloneable, Map, JSONAware, JSONStreamAware
A JSON object. Key value pairs are unordered. JSONObject supports java.util.Map interface.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEscape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).private static StringtoJSONString(String key, Object value, StringBuffer sb) static StringtoJSONString(Map map) Convert a map to JSON text.toString()static StringvoidwriteJSONString(Writer out) write JSON string to out.static voidwriteJSONString(Map map, Writer out) Encode a map into JSON text and write it to out.Methods inherited from class HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class AbstractMap
equals, hashCodeMethods inherited from interface 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
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
JSONObject
public JSONObject() -
JSONObject
Allows creation of a JSONObject from a Map. After that, both the generated JSONObject and the Map can be modified independently.- Parameters:
map-
-
-
Method Details
-
writeJSONString
Encode a map into JSON text and write it to out. If this map is also a JSONAware or JSONStreamAware, JSONAware or JSONStreamAware specific behaviours will be ignored at this top level.- Parameters:
map-out-- Throws:
IOException- See Also:
-
writeJSONString
Description copied from interface:JSONStreamAwarewrite JSON string to out.- Specified by:
writeJSONStringin interfaceJSONStreamAware- Throws:
IOException
-
toJSONString
-
toJSONString
- Specified by:
toJSONStringin interfaceJSONAware- Returns:
- JSON text
-
toJSONString
-
toString
- Overrides:
toStringin classAbstractMap
-
toString
-
escape
-