Package com.api.json
Interface JSONArtifact
-
- All Known Implementing Classes:
JSONArray,JSONObject
public interface JSONArtifactInterface class to define a set of generic apis both JSONObject and JSON array implement. This is namely so that functions such as serialize, which are common between the two, can be easily invoked.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Stringserialize()Convert this object into a String of JSON text.Stringserialize(boolean verbose)voidserialize(OutputStream os)Convert this object into a stream of JSON text.voidserialize(OutputStream os, boolean verbose)Convert this object into a stream of JSON text.voidserialize(Writer writer)Convert this object into a stream of JSON text.voidserialize(Writer writer, boolean verbose)Convert this object into a stream of JSON text, specifying verbosity.StringtoString(StringBuilder sb, int indent, int incr)Abstract method to help with recursive formatting of JSON into a String
-
-
-
Method Detail
-
serialize
String serialize() throws IOException
Convert this object into a String of JSON text.- Returns:
- String containing the JSON formatted according to the verbose flag.
- Throws:
IOException- Thrown on IO errors during serialization.
-
serialize
String serialize(boolean verbose) throws IOException
- Parameters:
verbose- Whether or not to write the JSON text in a verbose format.- Returns:
- String containing the JSON formatted according to the verbose flag.
- Throws:
IOException- Thrown on IO errors during serialization.
-
serialize
void serialize(OutputStream os) throws IOException
Convert this object into a stream of JSON text. Same as calling serialize(os,false); Note that encoding is always written as UTF-8, as per JSON spec.- Parameters:
os- The output stream to serialize data to.- Throws:
IOException- Thrown on IO errors during serialization.
-
serialize
void serialize(OutputStream os, boolean verbose) throws IOException
Convert this object into a stream of JSON text. Same as calling serialize(writer,false); Note that encoding is always written as UTF-8, as per JSON spec.- Parameters:
os- The output stream to serialize data to.verbose- Whether or not to write the JSON text in a verbose format.- Throws:
IOException- Thrown on IO errors during serialization.
-
serialize
void serialize(Writer writer) throws IOException
Convert this object into a stream of JSON text. Same as calling serialize(writer,false);- Parameters:
writer- The writer which to serialize the JSON text to.- Throws:
IOException- Thrown on IO errors during serialization.
-
serialize
void serialize(Writer writer, boolean verbose) throws IOException
Convert this object into a stream of JSON text, specifying verbosity.- Parameters:
writer- The writer which to serialize the JSON text to.verbose- Whether or not to write the JSON text in a verbose format.- Throws:
IOException- Thrown on IO errors during serialization.
-
toString
String toString(StringBuilder sb, int indent, int incr)
Abstract method to help with recursive formatting of JSON into a String- Parameters:
sb- Buffer to receive formatted JSON contentindent- The amount of indentation expected in the formatted output.incr- the amount of incremental spacing used for formatted output.- Returns:
- Formatted JSON output.
-
-