org.springframework.extensions.webscripts.json
Class JSONWriter
java.lang.Object
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JSONWriter
public JSONWriter(Writer out)
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.