org.json.simple
Class JSONObject

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by org.json.simple.JSONObject
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map, JSONAware, JSONStreamAware

public class JSONObject
extends java.util.HashMap
implements java.util.Map, JSONAware, JSONStreamAware

A JSON object. Key value pairs are unordered. JSONObject supports java.util.Map interface.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
JSONObject()
           
 
Method Summary
static java.lang.String escape(java.lang.String s)
          Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
 java.lang.String toJSONString()
           
static java.lang.String toJSONString(java.util.Map map)
          Convert a map to JSON text.
 java.lang.String toString()
           
static java.lang.String toString(java.lang.String key, java.lang.Object value)
           
static void writeJSONString(java.util.Map map, java.io.Writer out)
          Encode a map into JSON text and write it to out.
 void writeJSONString(java.io.Writer out)
          write JSON string to out.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, 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, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

JSONObject

public JSONObject()
Method Detail

writeJSONString

public static void writeJSONString(java.util.Map map,
                                   java.io.Writer out)
                            throws java.io.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:
java.io.IOException
See Also:
JSONValue.writeJSONString(Object, Writer)

writeJSONString

public void writeJSONString(java.io.Writer out)
                     throws java.io.IOException
Description copied from interface: JSONStreamAware
write JSON string to out.

Specified by:
writeJSONString in interface JSONStreamAware
Throws:
java.io.IOException

toJSONString

public static java.lang.String toJSONString(java.util.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:
JSONValue.toJSONString(Object)

toJSONString

public java.lang.String toJSONString()
Specified by:
toJSONString in interface JSONAware
Returns:
JSON text

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractMap

toString

public static java.lang.String toString(java.lang.String key,
                                        java.lang.Object value)

escape

public static java.lang.String escape(java.lang.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:
JSONValue.escape(String)