Package org.jfree.data.json.impl
Class JSONObject
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap
-
- org.jfree.data.json.impl.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.
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description JSONObject()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
toJSONString()
Returns a JSON string representing this object.private static java.lang.String
toJSONString(java.lang.String key, java.lang.Object value, java.lang.StringBuffer sb)
Writes a key and value to a JSON string.static java.lang.String
toJSONString(java.util.Map map)
Convert a map to JSON text.java.lang.String
toString()
Returns a string representation of this object.static java.lang.String
toString(java.lang.String key, java.lang.Object value)
Returns a JSON string fragment containing the key and value.void
writeJSONString(java.io.Writer out)
Writes a JSON string representing this object instance to the specified output writer.static void
writeJSONString(java.util.Map map, java.io.Writer out)
Encode a map into JSON text and write it to out.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
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 aJSONAware
orJSONStreamAware
,JSONAware
orJSONStreamAware
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:
java.io.IOException
- if there is an I/O problem.- See Also:
JSONValue.writeJSONString(Object, Writer)
-
writeJSONString
public void writeJSONString(java.io.Writer out) throws java.io.IOException
Writes a JSON string representing this object instance to the specified output writer.- Specified by:
writeJSONString
in interfaceJSONStreamAware
- Parameters:
out
- the output writer (null
not permitted).- Throws:
java.io.IOException
- if there is an I/O problem.
-
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 aJSONAware
,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:
JSONValue.toJSONString(Object)
-
toJSONString
public java.lang.String toJSONString()
Returns a JSON string representing this object.- Specified by:
toJSONString
in interfaceJSONAware
- Returns:
- A JSON string.
-
toJSONString
private static java.lang.String toJSONString(java.lang.String key, java.lang.Object value, java.lang.StringBuffer sb)
Writes a key and value to a JSON string.- Parameters:
key
- the key (null
permitted).value
- the value (null
permitted).sb
- a string buffer (null
not permitted).- Returns:
- A JSON string fragment representing the key and value.
-
toString
public java.lang.String toString()
Returns a string representation of this object.- Overrides:
toString
in classjava.util.AbstractMap
- Returns:
- A string.
-
toString
public static java.lang.String toString(java.lang.String key, java.lang.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.
-
-