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(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, setHtmlSafe, setIndent, setLenient, setSerializeNulls
private 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
JsonWriter
JsonWriter.endArray()
.beginArray
in class JsonWriter
java.io.IOException
public JsonWriter endArray() throws java.io.IOException
JsonWriter
endArray
in class JsonWriter
java.io.IOException
public JsonWriter beginObject() throws java.io.IOException
JsonWriter
JsonWriter.endObject()
.beginObject
in class JsonWriter
java.io.IOException
public JsonWriter endObject() throws java.io.IOException
JsonWriter
endObject
in class JsonWriter
java.io.IOException
public JsonWriter name(java.lang.String name) throws java.io.IOException
JsonWriter
name
in class JsonWriter
name
- the name of the forthcoming value. May not be null.java.io.IOException
public JsonWriter value(java.lang.String value) throws java.io.IOException
JsonWriter
value
.value
in class JsonWriter
value
- the literal string value, or null to encode a null literal.java.io.IOException
public JsonWriter nullValue() throws java.io.IOException
JsonWriter
null
.nullValue
in class JsonWriter
java.io.IOException
public JsonWriter value(boolean value) throws java.io.IOException
JsonWriter
value
.value
in class JsonWriter
java.io.IOException
public JsonWriter value(double value) throws java.io.IOException
JsonWriter
value
.value
in class JsonWriter
value
- a finite value. May not be NaNs
or
infinities
.java.io.IOException
public JsonWriter value(long value) throws java.io.IOException
JsonWriter
value
.value
in class JsonWriter
java.io.IOException
public JsonWriter value(java.lang.Number value) throws java.io.IOException
JsonWriter
value
.value
in class JsonWriter
value
- a finite value. May not be NaNs
or
infinities
.java.io.IOException
public void flush() throws java.io.IOException
JsonWriter
Writer
and flushes that writer.flush
in interface java.io.Flushable
flush
in class JsonWriter
java.io.IOException
public void close() throws java.io.IOException
JsonWriter
Writer
.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class JsonWriter
java.io.IOException
- if the JSON document is incomplete.