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

OutputStream write(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

OutputStream write(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

OutputStream write(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

Writer write(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

Writer write(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

Writer write(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

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

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

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-2012 The Apache Software Foundation. All Rights Reserved.