org.springframework.extensions.webscripts.json
Class JSONWriter

java.lang.Object
  extended by org.springframework.extensions.webscripts.json.JSONWriter

public final class JSONWriter
extends Object

Fast and simple JSON stream writer. Wraps a Writer to output a JSON object stream. No intermediate objects are created - writes are immediate to the underlying stream. Quoted and correct JSON encoding is performed on string values, - encoding is not performed on key names - it is assumed they are simple strings. The developer must call JSONWriter.encodeJSONString() on the key name if required.

Author:
Kevin Roast

Constructor Summary
JSONWriter(Writer out)
           
 
Method Summary
static String encodeJSONString(String s)
           
 void endArray()
           
 void endObject()
           
 void endValue()
           
 void startArray()
           
 void startObject()
           
 void startValue(String name)
           
 void writeNullValue(String name)
           
 void writeValue(String name, boolean value)
           
 void writeValue(String name, int value)
           
 void writeValue(String name, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONWriter

public JSONWriter(Writer out)
Method Detail

startArray

public void startArray()
                throws IOException
Throws:
IOException

endArray

public void endArray()
              throws IOException
Throws:
IOException

startObject

public void startObject()
                 throws IOException
Throws:
IOException

endObject

public void endObject()
               throws IOException
Throws:
IOException

startValue

public void startValue(String name)
                throws IOException
Throws:
IOException

endValue

public void endValue()

writeValue

public void writeValue(String name,
                       String value)
                throws IOException
Throws:
IOException

writeValue

public void writeValue(String name,
                       int value)
                throws IOException
Throws:
IOException

writeValue

public void writeValue(String name,
                       boolean value)
                throws IOException
Throws:
IOException

writeNullValue

public void writeNullValue(String name)
                    throws IOException
Throws:
IOException

encodeJSONString

public static String encodeJSONString(String s)


Copyright © 2009 SpringSource, Inc. All Rights Reserved.