Class JSONStringer

  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
Constructor Summary
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


public JSONStringer()
Method Detail


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.

toString in class Object


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

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