public class

JSONObject

extends HashMap<K, V>
implements JSONAware JSONStreamAware Map<K, V>
java.lang.Object
   ↳ java.util.AbstractMap<K, V>
     ↳ java.util.HashMap<K, V>
       ↳ com.pnfsoftware.jeb.util.encoding.json.JSONObject

Class Overview

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

Summary

Public Constructors
JSONObject()
JSONObject(Map map)
Allows creation of a JSONObject from a Map.
Public Methods
static String escape(String s)
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.
String toJSONString()
static String toString(String key, Object value)
String toString()
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.
[Expand]
Inherited Methods
From class java.util.HashMap
From class java.util.AbstractMap
From class java.lang.Object
From interface com.pnfsoftware.jeb.util.encoding.json.JSONAware
From interface com.pnfsoftware.jeb.util.encoding.json.JSONStreamAware
From interface java.util.Map

Public Constructors

public JSONObject ()

public JSONObject (Map map)

Allows creation of a JSONObject from a Map. After that, both the generated JSONObject and the Map can be modified independently.

Public Methods

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.

See Also

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.

Returns
  • JSON text, or "null" if map is null.

public String toJSONString ()

public static String toString (String key, Object value)

public String toString ()

public void writeJSONString (Writer out)

write JSON string to out.

Throws
IOException

public static void writeJSONString (Map map, Writer out)

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.

Throws
IOException