Package com.google.gson.internal.bind
Class JsonTreeWriter
- java.lang.Object
-
- com.google.gson.stream.JsonWriter
-
- com.google.gson.internal.bind.JsonTreeWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public final class JsonTreeWriter extends JsonWriter
This writer creates a JsonElement.
-
-
Constructor Summary
Constructors Constructor Description JsonTreeWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonWriterbeginArray()Begins encoding a new array.JsonWriterbeginObject()Begins encoding a new object.voidclose()Flushes and closes this writer and the underlyingWriter.JsonWriterendArray()Ends encoding the current array.JsonWriterendObject()Ends encoding the current object.voidflush()Ensures all buffered data is written to the underlyingWriterand flushes that writer.JsonElementget()Returns the top level object produced by this writer.JsonWritername(java.lang.String name)Encodes the property name.JsonWriternullValue()Encodesnull.JsonWritervalue(boolean value)Encodesvalue.JsonWritervalue(double value)Encodesvalue.JsonWritervalue(long value)Encodesvalue.JsonWritervalue(java.lang.Boolean value)Encodesvalue.JsonWritervalue(java.lang.Number value)Encodesvalue.JsonWritervalue(java.lang.String value)Encodesvalue.-
Methods inherited from class com.google.gson.stream.JsonWriter
getSerializeNulls, isHtmlSafe, isLenient, jsonValue, setHtmlSafe, setIndent, setLenient, setSerializeNulls
-
-
-
-
Method Detail
-
get
public JsonElement get()
Returns the top level object produced by this writer.
-
beginArray
public JsonWriter beginArray() throws java.io.IOException
Description copied from class:JsonWriterBegins encoding a new array. Each call to this method must be paired with a call toJsonWriter.endArray().- Overrides:
beginArrayin classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
endArray
public JsonWriter endArray() throws java.io.IOException
Description copied from class:JsonWriterEnds encoding the current array.- Overrides:
endArrayin classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
beginObject
public JsonWriter beginObject() throws java.io.IOException
Description copied from class:JsonWriterBegins encoding a new object. Each call to this method must be paired with a call toJsonWriter.endObject().- Overrides:
beginObjectin classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
endObject
public JsonWriter endObject() throws java.io.IOException
Description copied from class:JsonWriterEnds encoding the current object.- Overrides:
endObjectin classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
name
public JsonWriter name(java.lang.String name) throws java.io.IOException
Description copied from class:JsonWriterEncodes the property name.- Overrides:
namein classJsonWriter- Parameters:
name- the name of the forthcoming value. May not be null.- Returns:
- this writer.
- Throws:
java.io.IOException
-
value
public JsonWriter value(java.lang.String value) throws java.io.IOException
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Parameters:
value- the literal string value, or null to encode a null literal.- Returns:
- this writer.
- Throws:
java.io.IOException
-
nullValue
public JsonWriter nullValue() throws java.io.IOException
Description copied from class:JsonWriterEncodesnull.- Overrides:
nullValuein classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
value
public JsonWriter value(boolean value) throws java.io.IOException
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
value
public JsonWriter value(java.lang.Boolean value) throws java.io.IOException
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
value
public JsonWriter value(double value) throws java.io.IOException
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Parameters:
value- a finite value. May not beNaNsorinfinities.- Returns:
- this writer.
- Throws:
java.io.IOException
-
value
public JsonWriter value(long value) throws java.io.IOException
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Returns:
- this writer.
- Throws:
java.io.IOException
-
value
public JsonWriter value(java.lang.Number value) throws java.io.IOException
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Parameters:
value- a finite value. May not beNaNsorinfinities.- Returns:
- this writer.
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOExceptionDescription copied from class:JsonWriterEnsures all buffered data is written to the underlyingWriterand flushes that writer.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classJsonWriter- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionDescription copied from class:JsonWriterFlushes and closes this writer and the underlyingWriter.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classJsonWriter- Throws:
java.io.IOException- if the JSON document is incomplete.
-
-