public class JSONObject extends java.util.HashMap implements JSONArtifact
| Constructor and Description |
|---|
JSONObject()
Create a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isValidObject(java.lang.Object object)
Return whether the object is a valid value for a property.
|
static boolean |
isValidType(java.lang.Class clazz)
Return whether the class is a valid type of value for a property.
|
static JSONObject |
parse(java.io.InputStream is)
Convert a stream of JSON text into object form.
|
static JSONObject |
parse(java.io.Reader reader)
Convert a stream (in reader form) of JSON text into object form.
|
static JSONObject |
parse(java.lang.String str)
Convert a String of JSON text into object form.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
(non-Javadoc)
|
java.lang.String |
serialize()
Convert this object into a String of JSON text.
|
java.lang.String |
serialize(boolean verbose)
Convert this object into a String of JSON text, specifying verbosity.
|
void |
serialize(java.io.OutputStream os)
Convert this object into a stream of JSON text.
|
void |
serialize(java.io.OutputStream os,
boolean verbose)
Convert this object into a stream of JSON text.
|
void |
serialize(java.io.Writer writer)
Convert this object into a stream of JSON text.
|
void |
serialize(java.io.Writer writer,
boolean verbose)
Convert this object into a stream of JSON text, specifying verbosity.
|
java.lang.String |
toString()
Over-ridden toString() method.
|
public static boolean isValidObject(java.lang.Object object)
object - The object to check for validity as a JSON property value.public static boolean isValidType(java.lang.Class clazz)
clazz - The class type to check for validity as a JSON object type.public static JSONObject parse(java.io.Reader reader) throws java.io.IOException
reader - The reader from which the JSON data is read.IOEXception - Thrown if an underlying IO error from the reader occurs, or if malformed JSON is read,java.io.IOExceptionpublic static JSONObject parse(java.lang.String str) throws java.io.IOException
str - The JSON string to parse into a Java Object.IOEXception - Thrown if malformed JSON is read,java.io.IOExceptionpublic static JSONObject parse(java.io.InputStream is) throws java.io.IOException
is - The inputStream from which to read the JSON. It will assume the input stream is in UTF-8 and read it as such.IOEXception - Thrown if an underlying IO error from the stream occurs, or if malformed JSON is read,java.io.IOExceptionpublic void serialize(java.io.OutputStream os)
throws java.io.IOException
serialize in interface JSONArtifactos - The output stream to serialize data to.java.io.IOException - Thrown on IO errors during serialization.public void serialize(java.io.OutputStream os,
boolean verbose)
throws java.io.IOException
serialize in interface JSONArtifactos - The output stream to serialize data to.verbose - Whether or not to write the JSON text in a verbose format.java.io.IOException - Thrown on IO errors during serialization.public void serialize(java.io.Writer writer)
throws java.io.IOException
serialize in interface JSONArtifactwriter - The writer which to serialize the JSON text to.java.io.IOException - Thrown on IO errors during serialization.public void serialize(java.io.Writer writer,
boolean verbose)
throws java.io.IOException
serialize in interface JSONArtifactwriter - The writer which to serialize the JSON text to.java.io.IOException - Thrown on IO errors during serialization.public java.lang.String serialize(boolean verbose)
throws java.io.IOException
serialize in interface JSONArtifactverbose - Whether or not to serialize in compressed for formatted Strings.java.io.IOException - Thrown on IO errors during serialization.public java.lang.String serialize()
throws java.io.IOException
serialize in interface JSONArtifactjava.io.IOException - Thrown on IO errors during serialization.public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mapput in class java.util.HashMapHashMap.put(java.lang.Object, java.lang.Object)public java.lang.String toString()
toString in class java.util.AbstractMap