Class JSONObject

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
org.jfree.data.json.impl.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.

This class is for internal use by JFreeChart, it is not part of the supported API and you should not call it directly. If you need JSON support in your project you should include JSON.simple (https://code.google.com/p/json-simple/) or some other JSON library directly in your project.
See Also:
  • Constructor Details

  • Method Details

    • 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 - the map to write (null permitted).
      out - the output writer (null not permitted).
      Throws:
      IOException - if there is an I/O problem.
      See Also:
    • writeJSONString

      public void writeJSONString(Writer out) throws IOException
      Writes a JSON string representing this object instance to the specified output writer.
      Specified by:
      writeJSONString in interface JSONStreamAware
      Parameters:
      out - the output writer (null not permitted).
      Throws:
      IOException - if there is an I/O problem.
    • 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 - the map (null permitted).
      Returns:
      JSON text, or "null" if map is null.
      See Also:
    • toJSONString

      public String toJSONString()
      Returns a JSON string representing this object.
      Specified by:
      toJSONString in interface JSONAware
      Returns:
      A JSON string.
    • toString

      public String toString()
      Returns a string representation of this object.
      Overrides:
      toString in class AbstractMap
      Returns:
      A string.
    • toString

      public static String toString(String key, Object value)
      Returns a JSON string fragment containing the key and value.
      Parameters:
      key - the key (null permitted).
      value - the value (null permitted).
      Returns:
      A JSON string fragment.