Class JSONObject
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
com.pnfsoftware.jeb.util.encoding.json.JSONObject
- All Implemented Interfaces:
JSONAware
,JSONStreamAware
,Serializable
,Cloneable
,Map
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 java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).static String
toJSONString
(Map map) Convert a map to JSON text.toString()
static String
void
writeJSONString
(Writer out) write JSON string to out.static void
writeJSONString
(Map map, Writer out) Encode a map into JSON text and write it to out.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, 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
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
-
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:
-
JSONValue.writeJSONString(Object, Writer)
-
writeJSONString
Description copied from interface:JSONStreamAware
write JSON string to out.- Specified by:
writeJSONString
in interfaceJSONStreamAware
- Throws:
IOException
-
toJSONString
Convert a map to JSON text. The result is a JSON object. If this map is also a JSONAware, JSONAware specific behaviours will be omitted at this top level.- Parameters:
map
-- Returns:
- JSON text, or "null" if map is null.
- See Also:
-
JSONValue.toJSONString(Object)
-
toJSONString
- Specified by:
toJSONString
in interfaceJSONAware
- Returns:
- JSON text
-
toString
- Overrides:
toString
in classAbstractMap
-
toString
-
escape
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F). It's the same as JSONValue.escape() only for compatibility here.- Parameters:
s
-- Returns:
- See Also:
-
JSONValue.escape(String)
-