org.apache.wink.json4j
Class JSONStringer

java.lang.Object
  extended by org.apache.wink.json4j.JSONWriter
      extended by org.apache.wink.json4j.JSONStringer

public class JSONStringer
extends JSONWriter

This class implements a JSONSringer, a basic convenience subclass of JSONWriter to allow for generating JSON strings quickly. This class exists for API compatibility to other popular JSON parsers.


Field Summary
 
Fields inherited from class org.apache.wink.json4j.JSONWriter
writer
 
Constructor Summary
JSONStringer()
           
 
Method Summary
 void close()
          Over-ride to do nothing for the stringer.
 String toString()
          Return a string of the stringer contents.
 
Methods inherited from class org.apache.wink.json4j.JSONWriter
array, endArray, endObject, flush, key, object, value, value, value, value, value, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSONStringer

public JSONStringer()
Method Detail

toString

public String toString()
Return a string of the stringer contents. This also terminates the Stringer and it cannot be used again. If any errors occur while trying to generate the JSON it returns an empty string.

Overrides:
toString in class Object

close

public void close()
           throws IOException,
                  IllegalStateException
Over-ride to do nothing for the stringer. Only toString() terminates the stringer object.

Overrides:
close in class JSONWriter
Throws:
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the writer position is in an object and a key has been placed, but a value has not been assigned or if the writer was already closed.


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