Package com.google.api.client.json.gson
Class GsonGenerator
java.lang.Object
com.google.api.client.json.JsonGenerator
com.google.api.client.json.gson.GsonGenerator
Low-level JSON serializer implementation based on GSON.
Implementation is not thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
Hack to support numbers encoded as a string for JsonWriter. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final GsonFactory
private final com.google.gson.stream.JsonWriter
-
Constructor Summary
ConstructorsConstructorDescriptionGsonGenerator
(GsonFactory factory, com.google.gson.stream.JsonWriter writer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the serializer and the underlying output stream or writer, and releases any memory associated with it.void
Requests that the output be pretty printed (by default it is not).void
flush()
Flushes any buffered content to the underlying output stream or writer.Returns the JSON factory from which this generator was created.void
writeBoolean
(boolean state) Writes a literal JSON boolean value ('true' or 'false').void
Writes a JSON end array character ']'.void
Writes a JSON end object character '}'.void
writeFieldName
(String name) Writes a JSON quoted field name.void
Writes a literal JSON null value.void
writeNumber
(double v) Writes a JSON double value.void
writeNumber
(float v) Writes a JSON float value.void
writeNumber
(int v) Writes a JSON int value.void
writeNumber
(long v) Writes a JSON long value.void
writeNumber
(String encodedValue) Writes a JSON numeric value that has already been encoded properly.void
Writes a JSON big decimal value.void
Writes a JSON big integer value.void
Writes a JSON start array character '['.void
Writes a JSON start object character '{'.void
writeString
(String value) Writes a JSON quoted string value.Methods inherited from class com.google.api.client.json.JsonGenerator
serialize
-
Field Details
-
writer
private final com.google.gson.stream.JsonWriter writer -
factory
-
-
Constructor Details
-
GsonGenerator
GsonGenerator(GsonFactory factory, com.google.gson.stream.JsonWriter writer)
-
-
Method Details
-
flush
Description copied from class:JsonGenerator
Flushes any buffered content to the underlying output stream or writer.- Specified by:
flush
in classJsonGenerator
- Throws:
IOException
-
close
Description copied from class:JsonGenerator
Closes the serializer and the underlying output stream or writer, and releases any memory associated with it.- Specified by:
close
in classJsonGenerator
- Throws:
IOException
-
getFactory
Description copied from class:JsonGenerator
Returns the JSON factory from which this generator was created.- Specified by:
getFactory
in classJsonGenerator
-
writeBoolean
Description copied from class:JsonGenerator
Writes a literal JSON boolean value ('true' or 'false').- Specified by:
writeBoolean
in classJsonGenerator
- Throws:
IOException
-
writeEndArray
Description copied from class:JsonGenerator
Writes a JSON end array character ']'.- Specified by:
writeEndArray
in classJsonGenerator
- Throws:
IOException
-
writeEndObject
Description copied from class:JsonGenerator
Writes a JSON end object character '}'.- Specified by:
writeEndObject
in classJsonGenerator
- Throws:
IOException
-
writeFieldName
Description copied from class:JsonGenerator
Writes a JSON quoted field name.- Specified by:
writeFieldName
in classJsonGenerator
- Throws:
IOException
-
writeNull
Description copied from class:JsonGenerator
Writes a literal JSON null value.- Specified by:
writeNull
in classJsonGenerator
- Throws:
IOException
-
writeNumber
Description copied from class:JsonGenerator
Writes a JSON int value.- Specified by:
writeNumber
in classJsonGenerator
- Throws:
IOException
-
writeNumber
Description copied from class:JsonGenerator
Writes a JSON long value.- Specified by:
writeNumber
in classJsonGenerator
- Throws:
IOException
-
writeNumber
Description copied from class:JsonGenerator
Writes a JSON big integer value.- Specified by:
writeNumber
in classJsonGenerator
- Throws:
IOException
-
writeNumber
Description copied from class:JsonGenerator
Writes a JSON double value.- Specified by:
writeNumber
in classJsonGenerator
- Throws:
IOException
-
writeNumber
Description copied from class:JsonGenerator
Writes a JSON float value.- Specified by:
writeNumber
in classJsonGenerator
- Throws:
IOException
-
writeNumber
Description copied from class:JsonGenerator
Writes a JSON big decimal value.- Specified by:
writeNumber
in classJsonGenerator
- Throws:
IOException
-
writeNumber
Description copied from class:JsonGenerator
Writes a JSON numeric value that has already been encoded properly.- Specified by:
writeNumber
in classJsonGenerator
- Throws:
IOException
-
writeStartArray
Description copied from class:JsonGenerator
Writes a JSON start array character '['.- Specified by:
writeStartArray
in classJsonGenerator
- Throws:
IOException
-
writeStartObject
Description copied from class:JsonGenerator
Writes a JSON start object character '{'.- Specified by:
writeStartObject
in classJsonGenerator
- Throws:
IOException
-
writeString
Description copied from class:JsonGenerator
Writes a JSON quoted string value.- Specified by:
writeString
in classJsonGenerator
- Throws:
IOException
-
enablePrettyPrint
Description copied from class:JsonGenerator
Requests that the output be pretty printed (by default it is not).Default implementation does nothing, but implementations may override to provide actual pretty printing.
- Overrides:
enablePrettyPrint
in classJsonGenerator
- Throws:
IOException
- possible I/O exception (unused in default implementation)
-