Class JsonTreeWriter
java.lang.Object
com.google.gson.stream.JsonWriter
com.google.gson.internal.bind.JsonTreeWriter
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
This writer creates a JsonElement.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBegins encoding a new array.Begins encoding a new object.voidclose()Flushes and closes this writer and the underlyingWriter.endArray()Ends encoding the current array.Ends encoding the current object.voidflush()Ensures all buffered data is written to the underlyingWriterand flushes that writer.get()Returns the top level object produced by this writer.Encodes the property name.Encodesnull.value(boolean value) Encodesvalue.value(double value) Encodesvalue.value(long value) Encodesvalue.Encodesvalue.Encodesvalue.Encodesvalue.Methods inherited from class JsonWriter
getSerializeNulls, isHtmlSafe, isLenient, jsonValue, setHtmlSafe, setIndent, setLenient, setSerializeNulls
-
Constructor Details
-
JsonTreeWriter
public JsonTreeWriter()
-
-
Method Details
-
get
Returns the top level object produced by this writer. -
beginArray
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:
IOException
-
endArray
Description copied from class:JsonWriterEnds encoding the current array.- Overrides:
endArrayin classJsonWriter- Returns:
- this writer.
- Throws:
IOException
-
beginObject
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:
IOException
-
endObject
Description copied from class:JsonWriterEnds encoding the current object.- Overrides:
endObjectin classJsonWriter- Returns:
- this writer.
- Throws:
IOException
-
name
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:
IOException
-
value
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:
IOException
-
nullValue
Description copied from class:JsonWriterEncodesnull.- Overrides:
nullValuein classJsonWriter- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Parameters:
value- a finite value. May not beNaNsorinfinities.- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriterEncodesvalue.- Overrides:
valuein classJsonWriter- Parameters:
value- a finite value. May not beNaNsorinfinities.- Returns:
- this writer.
- Throws:
IOException
-
flush
Description copied from class:JsonWriterEnsures all buffered data is written to the underlyingWriterand flushes that writer.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classJsonWriter- Throws:
IOException
-
close
Description copied from class:JsonWriterFlushes and closes this writer and the underlyingWriter.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classJsonWriter- Throws:
IOException- if the JSON document is incomplete.
-