public final class JsonTreeWriter extends JsonWriter
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
pendingName
The name for the next JSON object value.
|
private JsonElement |
product
the JSON element constructed by this writer.
|
private static JsonPrimitive |
SENTINEL_CLOSED
Added to the top of the stack when this writer is closed to cause following ops to fail.
|
private java.util.List<JsonElement> |
stack
The JsonElements and JsonArrays under modification, outermost to innermost.
|
private static java.io.Writer |
UNWRITABLE_WRITER |
| Constructor and Description |
|---|
JsonTreeWriter() |
| Modifier and Type | Method and Description |
|---|---|
JsonWriter |
beginArray()
Begins encoding a new array.
|
JsonWriter |
beginObject()
Begins encoding a new object.
|
void |
close()
Flushes and closes this writer and the underlying
Writer. |
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
Writer
and flushes that writer. |
JsonElement |
get()
Returns the top level object produced by this writer.
|
JsonWriter |
name(java.lang.String name)
Encodes the property name.
|
JsonWriter |
nullValue()
Encodes
null. |
private JsonElement |
peek() |
private void |
put(JsonElement value) |
JsonWriter |
value(boolean value)
Encodes
value. |
JsonWriter |
value(java.lang.Boolean value)
Encodes
value. |
JsonWriter |
value(double value)
Encodes
value. |
JsonWriter |
value(long value)
Encodes
value. |
JsonWriter |
value(java.lang.Number value)
Encodes
value. |
JsonWriter |
value(java.lang.String value)
Encodes
value. |
getSerializeNulls, isHtmlSafe, isLenient, jsonValue, setHtmlSafe, setIndent, setLenient, setSerializeNullsprivate static final java.io.Writer UNWRITABLE_WRITER
private static final JsonPrimitive SENTINEL_CLOSED
private final java.util.List<JsonElement> stack
private java.lang.String pendingName
private JsonElement product
public JsonElement get()
private JsonElement peek()
private void put(JsonElement value)
public JsonWriter beginArray() throws java.io.IOException
JsonWriterJsonWriter.endArray().beginArray in class JsonWriterjava.io.IOExceptionpublic JsonWriter endArray() throws java.io.IOException
JsonWriterendArray in class JsonWriterjava.io.IOExceptionpublic JsonWriter beginObject() throws java.io.IOException
JsonWriterJsonWriter.endObject().beginObject in class JsonWriterjava.io.IOExceptionpublic JsonWriter endObject() throws java.io.IOException
JsonWriterendObject in class JsonWriterjava.io.IOExceptionpublic JsonWriter name(java.lang.String name) throws java.io.IOException
JsonWritername in class JsonWritername - the name of the forthcoming value. May not be null.java.io.IOExceptionpublic JsonWriter value(java.lang.String value) throws java.io.IOException
JsonWritervalue.value in class JsonWritervalue - the literal string value, or null to encode a null literal.java.io.IOExceptionpublic JsonWriter nullValue() throws java.io.IOException
JsonWriternull.nullValue in class JsonWriterjava.io.IOExceptionpublic JsonWriter value(boolean value) throws java.io.IOException
JsonWritervalue.value in class JsonWriterjava.io.IOExceptionpublic JsonWriter value(java.lang.Boolean value) throws java.io.IOException
JsonWritervalue.value in class JsonWriterjava.io.IOExceptionpublic JsonWriter value(double value) throws java.io.IOException
JsonWritervalue.value in class JsonWritervalue - a finite value. May not be NaNs or
infinities.java.io.IOExceptionpublic JsonWriter value(long value) throws java.io.IOException
JsonWritervalue.value in class JsonWriterjava.io.IOExceptionpublic JsonWriter value(java.lang.Number value) throws java.io.IOException
JsonWritervalue.value in class JsonWritervalue - a finite value. May not be NaNs or
infinities.java.io.IOExceptionpublic void flush()
throws java.io.IOException
JsonWriterWriter
and flushes that writer.flush in interface java.io.Flushableflush in class JsonWriterjava.io.IOExceptionpublic void close()
throws java.io.IOException
JsonWriterWriter.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class JsonWriterjava.io.IOException - if the JSON document is incomplete.