Serializable
, Cloneable
, Map<String,Object>
, JSONAware
, JSONAwareEx
, JSONStreamAware
, JSONStreamAwareEx
public class JSONObject extends HashMap<String,Object> implements JSONAware, JSONAwareEx, JSONStreamAwareEx
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
Constructor | Description |
---|---|
JSONObject() |
|
JSONObject(Map<String,?> map) |
Allows creation of a JSONObject from a Map.
|
Modifier and Type | Method | Description |
---|---|---|
static String |
escape(String s) |
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters
(U+0000 through U+001F).
|
void |
merge(Object o2) |
|
protected static JSONArray |
merge(JSONArray o1,
Object o2) |
|
protected static JSONObject |
merge(JSONObject o1,
Object o2) |
|
String |
toJSONString() |
|
static String |
toJSONString(Map<String,? extends Object> map) |
|
static String |
toJSONString(Map<String,? extends Object> map,
JSONStyle compression) |
Convert a map to JSON text.
|
String |
toJSONString(JSONStyle compression) |
|
String |
toString() |
|
String |
toString(JSONStyle compression) |
|
static void |
writeJSON(Map<String,? extends Object> map,
Appendable out,
JSONStyle compression) |
Encode a map into JSON text and write it to out.
|
static void |
writeJSON(Map<String,Object> map,
Appendable out) |
|
void |
writeJSONString(Appendable out) |
serialize Object as json to an stream
|
void |
writeJSONString(Appendable out,
JSONStyle compression) |
serialize Object as json to an stream
|
equals, hashCode
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public static String escape(String s)
JSONValue.escape(String)
public static String toJSONString(Map<String,? extends Object> map, JSONStyle compression)
map
- JSONValue.toJSONString(Object)
public static void writeJSON(Map<String,Object> map, Appendable out) throws IOException
IOException
public static void writeJSON(Map<String,? extends Object> map, Appendable out, JSONStyle compression) throws IOException
IOException
JSONValue.writeJSONString(Object, Appendable)
public void writeJSONString(Appendable out) throws IOException
writeJSONString
in interface JSONStreamAware
IOException
public void writeJSONString(Appendable out, JSONStyle compression) throws IOException
writeJSONString
in interface JSONStreamAwareEx
IOException
public void merge(Object o2)
protected static JSONObject merge(JSONObject o1, Object o2)
public String toJSONString()
toJSONString
in interface JSONAware
public String toJSONString(JSONStyle compression)
toJSONString
in interface JSONAwareEx
public String toString()
toString
in class AbstractMap<String,Object>