public interface JsonWriter
JsonWriter interface.
| Modifier and Type | Method and Description |
|---|---|
JsonWriter |
beginArray()
Begins encoding a new array.
|
JsonWriter |
beginObject()
Begins encoding a new object.
|
JsonWriter |
cancelName()
cancelName
|
void |
close()
Flushes and closes this writer and the underlying
StringBuilder. |
JsonWriter |
endArray()
Ends encoding the current array.
|
JsonWriter |
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
|
JsonWriter |
name(String name)
Encodes the property name.
|
JsonWriter |
nullValue()
Encodes
null. |
JsonWriter |
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.
|
JsonWriter |
unescapeName(String name)
Encodes the property name without escaping it.
|
JsonWriter |
unescapeValue(String value)
Encodes
value without escaping it. |
JsonWriter |
value(boolean value)
Encodes
value. |
JsonWriter |
value(double value)
Encodes
value. |
JsonWriter |
value(long value)
Encodes
value. |
JsonWriter |
value(Number value)
Encodes
value. |
JsonWriter |
value(String value)
Encodes
value. |
void setIndent(String indent)
indent.isEmpty() the encoded document
will be compact. Otherwise the encoded document will be more
human-readable.indent - a string containing only whitespace.void setLenient(boolean lenient)
NaNs or infinities.
lenient - a boolean.void setSerializeNulls(boolean serializeNulls)
serializeNulls - a boolean.boolean getSerializeNulls()
getSerializeNulls
JsonWriter beginArray()
endArray().JsonWriter endArray()
JsonWriter beginObject()
endObject().JsonWriter endObject()
JsonWriter name(String name)
name - the name of the forthcoming value. May not be null.JsonWriter unescapeName(String name)
name - the name of the forthcoming value. May not be null.JsonWriter value(String value)
value.value - the literal string value, or null to encode a null literal.JsonWriter unescapeValue(String value)
value without escaping it.value - the literal string value, or null to encode a null literal.JsonWriter nullValue()
null.JsonWriter cancelName()
cancelName
JsonWriter object.JsonWriter value(boolean value)
value.value - a boolean.JsonWriter value(double value)
value.value - a finite value. May not be NaNs or
infinities.JsonWriter value(long value)
value.value - a long.JsonWriter value(Number value)
value.value - a finite value. May not be NaNs or
infinities.JsonWriter rawValue(Object value)
value.toString() as is.value - a value .void flush()
StringBuilder
and flushes that writer.void close()
StringBuilder.String getOutput()
getOutput
Copyright © 2020. All rights reserved.