net.tomp2p.examples.json.simple
Class JSONObject
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
net.tomp2p.examples.json.simple.JSONObject
- All Implemented Interfaces:
- Serializable, Cloneable, Map, JSONAware, JSONStreamAware
public class JSONObject
- extends HashMap
- implements Map, JSONAware, JSONStreamAware
A JSON object. Key value pairs are unordered. JSONObject supports java.util.Map interface.
- Author:
- FangYidong
- See Also:
- Serialized Form
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Methods inherited from class java.util.HashMap |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
JSONObject
public JSONObject()
writeJSONString
public static void writeJSONString(Map map,
Writer out)
throws IOException
- 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:
org.json.simple.JSONValue#writeJSONString(Object, Writer)
writeJSONString
public void writeJSONString(Writer out)
throws IOException
- Description copied from interface:
JSONStreamAware
- write JSON string to out.
- Specified by:
writeJSONString
in interface JSONStreamAware
- Throws:
IOException
toJSONString
public static String toJSONString(Map map)
- 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:
org.json.simple.JSONValue#toJSONString(Object)
toJSONString
public String toJSONString()
- Specified by:
toJSONString
in interface JSONAware
- Returns:
- JSON text
toString
public String toString()
- Overrides:
toString
in class AbstractMap
toString
public static String toString(String key,
Object value)
escape
public static String escape(String s)
- 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:
org.json.simple.JSONValue#escape(String)
Copyright © 2012. All Rights Reserved.