org.apache.wink.json4j
Interface JSONArtifact

All Known Implementing Classes:
JSONArray, JSONObject, OrderedJSONObject

public interface JSONArtifact

Interface class to define a set of generic apis both JSONObject and JSONArray implement. This is namely so that functions such as write, which are common between the two, can be easily invoked without knowing the object type.


Method Summary
 java.lang.String write()
          Convert this object into a String of JSON text.
 java.lang.String write(boolean verbose)
          Convert this object into a String of JSON text, specifying whether to use verbose (tab-indented) output or not.
 java.lang.String write(int indentDepth)
          Convert this object into a String of JSON text, specifying how many spaces should be used for each indent.
 java.io.OutputStream write(java.io.OutputStream os)
          Write this object to the stream as JSON text in UTF-8 encoding.
 java.io.OutputStream write(java.io.OutputStream os, boolean verbose)
          Write this object to the stream as JSON text in UTF-8 encoding, specifying whether to use verbose (tab-indented) output or not.
 java.io.OutputStream write(java.io.OutputStream os, int indentDepth)
          Write this object to the stream as JSON text in UTF-8 encoding, specifying how many spaces should be used for each indent.
 java.io.Writer write(java.io.Writer writer)
          Write this object to the writer as JSON text.
 java.io.Writer write(java.io.Writer writer, boolean verbose)
          Writer this object to the writer as JSON text, specifying whether to use verbose (tab-indented) output or not.
 java.io.Writer write(java.io.Writer writer, int indentDepth)
          Write this object to the writer as JSON text, specifying how many spaces should be used for each indent.
 

Method Detail

write

java.io.OutputStream write(java.io.OutputStream os)
                           throws JSONException
Write this object to the stream as JSON text in UTF-8 encoding. Same as calling write(os,false); Note that encoding is always written as UTF-8, as per JSON spec.

Parameters:
os - The output stream to write data to.
Returns:
The passed in OutputStream.
Throws:
JSONException - Thrown on errors during serialization.

write

java.io.OutputStream write(java.io.OutputStream os,
                           boolean verbose)
                           throws JSONException
Write this object to the stream as JSON text in UTF-8 encoding, specifying whether to use verbose (tab-indented) output or not. Note that encoding is always written as UTF-8, as per JSON spec.

Parameters:
os - The output stream to write data to.
verbose - Whether or not to write the JSON text in a verbose format. If true, will indent via tab.
Returns:
The passed in OutputStream.
Throws:
JSONException - Thrown on errors during serialization.

write

java.io.OutputStream write(java.io.OutputStream os,
                           int indentDepth)
                           throws JSONException
Write this object to the stream as JSON text in UTF-8 encoding, specifying how many spaces should be used for each indent. This is an alternate indent style to using tabs.

Parameters:
indentDepth - How many spaces to use for each indent. The value should be between one to eight. Less than one means no indenting, greater than 8 and it will just use tab.
Returns:
The passed in OutputStream.
Throws:
JSONException - Thrown on errors during serialization.

write

java.io.Writer write(java.io.Writer writer)
                     throws JSONException
Write this object to the writer as JSON text. Same as calling write(writer,false);

Parameters:
writer - The writer which to write the JSON text to.
Returns:
The passed in writer.
Throws:
JSONException - Thrown on errors during serialization.

write

java.io.Writer write(java.io.Writer writer,
                     boolean verbose)
                     throws JSONException
Writer this object to the writer as JSON text, specifying whether to use verbose (tab-indented) output or not. be used for each indent. This is an alternate indent style to using tabs.

Parameters:
writer - The writer which to write the JSON text to.
Returns:
The passed in writer.
Throws:
JSONException - Thrown on errors during serialization.

write

java.io.Writer write(java.io.Writer writer,
                     int indentDepth)
                     throws JSONException
Write this object to the writer as JSON text, specifying how many spaces should be used for each indent. This is an alternate indent style to using tabs.

Parameters:
writer - The writer which to write the JSON text to.
indentDepth - How many spaces to use for each indent. The value should be between one to eight.
Returns:
The passed in writer.
Throws:
JSONException - Thrown on errors during serialization.

write

java.lang.String write(boolean verbose)
                       throws JSONException
Convert this object into a String of JSON text, specifying whether to use verbose (tab-indented) output or not.

Parameters:
verbose - Whether or not to write in compressed format. Less than one means no indenting, greater than 8 and it will just use tab.
Throws:
JSONException - Thrown on errors during serialization.

write

java.lang.String write(int indentDepth)
                       throws JSONException
Convert this object into a String of JSON text, specifying how many spaces should be used for each indent. This is an alternate indent style to using tabs.

Parameters:
indentDepth - How many spaces to use for each indent. The value should be between one to eight. Less than one means no indenting, greater than 8 and it will just use tab.
Throws:
JSONException - Thrown on errors during serialization.

write

java.lang.String write()
                       throws JSONException
Convert this object into a String of JSON text. Same as write(false);

Throws:
JSONException - Thrown on errors during serialization.


Copyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.