public class FastJsonWriter extends Object implements JsonWriter
FastJsonWriter class.
| 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()
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()
getOutput
|
boolean |
getSerializeNulls()
getSerializeNulls
|
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(long value)
Encodes
value. |
FastJsonWriter |
value(Number value)
Encodes
value. |
FastJsonWriter |
value(String value)
Encodes
value. |
public FastJsonWriter(StringBuilder out)
out.out - a StringBuilder object.public final void setIndent(String indent)
indent.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)
NaNs or infinities.
setLenient in interface JsonWriterlenient - a boolean.public boolean isLenient()
public final void setSerializeNulls(boolean serializeNulls)
setSerializeNulls in interface JsonWriterserializeNulls - a boolean.public final boolean getSerializeNulls()
getSerializeNulls
Returns true if object members are serialized when their value is null. This has no impact on array elements. The default is true.
getSerializeNulls in interface JsonWriterpublic FastJsonWriter beginArray()
JsonWriter.endArray().beginArray in interface JsonWriterpublic FastJsonWriter endArray()
endArray in interface JsonWriterpublic FastJsonWriter beginObject()
JsonWriter.endObject().beginObject in interface JsonWriterpublic FastJsonWriter endObject()
endObject in interface JsonWriterpublic FastJsonWriter name(String name)
name in interface JsonWritername - the name of the forthcoming value. May not be null.public FastJsonWriter unescapeName(String name)
unescapeName in interface JsonWritername - the name of the forthcoming value. May not be null.public FastJsonWriter value(String value)
value.value in interface JsonWritervalue - the literal string value, or null to encode a null literal.public FastJsonWriter unescapeValue(String value)
value without escaping it.unescapeValue in interface JsonWritervalue - the literal string value, or null to encode a null literal.public FastJsonWriter nullValue()
null.nullValue in interface JsonWriterpublic FastJsonWriter cancelName()
cancelName
cancelName in interface JsonWriterJsonWriter object.public FastJsonWriter value(boolean value)
value.value in interface JsonWritervalue - a boolean.public FastJsonWriter value(double value)
value.value in interface JsonWritervalue - a finite value. May not be NaNs or
infinities.public FastJsonWriter value(long value)
value.value in interface JsonWritervalue - a long.public FastJsonWriter value(Number value)
value.value in interface JsonWritervalue - a finite value. May not be NaNs or
infinities.public FastJsonWriter rawValue(Object value)
value.toString() as is.rawValue in interface JsonWritervalue - a value .public void flush()
StringBuilder
and flushes that writer.flush in interface JsonWriterpublic void close()
StringBuilder.close in interface JsonWriterpublic String getOutput()
getOutput
getOutput in interface JsonWriterCopyright © 2019. All rights reserved.