public class FastJsonWriter extends Object implements JsonWriter
DefaultJsonWriter but uses JsonUtils.escapeValue(String) instead of the REPLACEMENT_CHARS array.| Constructor and Description |
|---|
FastJsonWriter(StringBuilder out)
Creates a new instance that writes a JSON-encoded stream to
out. |
| Modifier and Type | Method and Description |
|---|---|
FastJsonWriter |
beginArray()
Begins encoding a new array.
|
FastJsonWriter |
beginObject()
Begins encoding a new object.
|
FastJsonWriter |
cancelName() |
void |
close()
Flushes and closes this writer and the underlying
StringBuilder. |
FastJsonWriter |
endArray()
Ends encoding the current array.
|
FastJsonWriter |
endObject()
Ends encoding the current object.
|
void |
flush()
Ensures all buffered data is written to the underlying
StringBuilder
and flushes that writer. |
String |
getOutput() |
boolean |
getSerializeNulls()
Returns true if object members are serialized when their value is null.
|
boolean |
isLenient()
Returns true if this writer has relaxed syntax rules.
|
FastJsonWriter |
name(String name)
Encodes the property name.
|
FastJsonWriter |
nullValue()
Encodes
null. |
FastJsonWriter |
rawValue(Object value)
Encodes
value.toString() as is. |
void |
setIndent(String indent)
Sets the indentation string to be repeated for each level of indentation
in the encoded document.
|
void |
setLenient(boolean lenient)
Configure this writer to relax its syntax rules.
|
void |
setSerializeNulls(boolean serializeNulls)
Sets whether object members are serialized when their value is null.
|
FastJsonWriter |
unescapeName(String name)
Encodes the property name without escaping it.
|
FastJsonWriter |
unescapeValue(String value)
Encodes
value without escaping it. |
FastJsonWriter |
value(boolean value)
Encodes
value. |
FastJsonWriter |
value(double value)
Encodes
value. |
FastJsonWriter |
value(com.google.gwt.core.client.JavaScriptObject value)
Encodes
value. |
FastJsonWriter |
value(long value)
Encodes
value. |
FastJsonWriter |
value(Number value)
Encodes
value. |
FastJsonWriter |
value(String value)
Encodes
value. |
public FastJsonWriter(StringBuilder out)
out.public final void setIndent(String indent)
JsonWriterindent.isEmpty() the encoded document
will be compact. Otherwise the encoded document will be more
human-readable.setIndent in interface JsonWriterindent - a string containing only whitespace.public final void setLenient(boolean lenient)
JsonWriterNaNs or infinities.
setLenient in interface JsonWriterpublic boolean isLenient()
public final void setSerializeNulls(boolean serializeNulls)
JsonWritersetSerializeNulls in interface JsonWriterpublic final boolean getSerializeNulls()
getSerializeNulls in interface JsonWriterpublic FastJsonWriter beginArray()
JsonWriterJsonWriter.endArray().beginArray in interface JsonWriterpublic FastJsonWriter endArray()
JsonWriterendArray in interface JsonWriterpublic FastJsonWriter beginObject()
JsonWriterJsonWriter.endObject().beginObject in interface JsonWriterpublic FastJsonWriter endObject()
JsonWriterendObject in interface JsonWriterpublic FastJsonWriter name(String name)
JsonWritername in interface JsonWritername - the name of the forthcoming value. May not be null.public FastJsonWriter unescapeName(String name)
JsonWriterunescapeName in interface JsonWritername - the name of the forthcoming value. May not be null.public FastJsonWriter value(String value)
JsonWritervalue.value in interface JsonWritervalue - the literal string value, or null to encode a null literal.public FastJsonWriter unescapeValue(String value)
JsonWritervalue without escaping it.unescapeValue in interface JsonWritervalue - the literal string value, or null to encode a null literal.public FastJsonWriter nullValue()
JsonWriternull.nullValue in interface JsonWriterpublic FastJsonWriter cancelName()
cancelName in interface JsonWriterpublic FastJsonWriter value(boolean value)
JsonWritervalue.value in interface JsonWriterpublic FastJsonWriter value(double value)
JsonWritervalue.value in interface JsonWritervalue - a finite value. May not be NaNs or
infinities.public FastJsonWriter value(long value)
JsonWritervalue.value in interface JsonWriterpublic FastJsonWriter value(Number value)
JsonWritervalue.value in interface JsonWritervalue - a finite value. May not be NaNs or
infinities.public FastJsonWriter value(com.google.gwt.core.client.JavaScriptObject value)
JsonWritervalue.value in interface JsonWritervalue - a value .public FastJsonWriter rawValue(Object value)
JsonWritervalue.toString() as is.rawValue in interface JsonWritervalue - a value .public void flush()
JsonWriterStringBuilder
and flushes that writer.flush in interface JsonWriterpublic void close()
JsonWriterStringBuilder.close in interface JsonWriterpublic String getOutput()
getOutput in interface JsonWriterCopyright © 2016. All Rights Reserved.