Class GsonGenerator
java.lang.Object
com.google.api.client.json.JsonGenerator
com.google.api.client.json.gson.GsonGenerator
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Low-level JSON serializer implementation based on GSON.
Implementation is not thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classHack to support numbers encoded as a string for JsonWriter. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final GsonFactoryprivate final com.google.gson.stream.JsonWriter -
Constructor Summary
ConstructorsConstructorDescriptionGsonGenerator(GsonFactory factory, com.google.gson.stream.JsonWriter writer) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the serializer and the underlying output stream or writer, and releases any memory associated with it.voidRequests that the output be pretty printed (by default it is not).voidflush()Flushes any buffered content to the underlying output stream or writer.Returns the JSON factory from which this generator was created.voidwriteBoolean(boolean state) Writes a literal JSON boolean value ('true' or 'false').voidWrites a JSON end array character ']'.voidWrites a JSON end object character '}'.voidwriteFieldName(String name) Writes a JSON quoted field name.voidWrites a literal JSON null value.voidwriteNumber(double v) Writes a JSON double value.voidwriteNumber(float v) Writes a JSON float value.voidwriteNumber(int v) Writes a JSON int value.voidwriteNumber(long v) Writes a JSON long value.voidwriteNumber(String encodedValue) Writes a JSON numeric value that has already been encoded properly.voidWrites a JSON big decimal value.voidWrites a JSON big integer value.voidWrites a JSON start array character '['.voidWrites a JSON start object character '{'.voidwriteString(String value) Writes a JSON quoted string value.Methods inherited from class 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:JsonGeneratorFlushes any buffered content to the underlying output stream or writer.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classJsonGenerator- Throws:
IOException
-
close
Description copied from class:JsonGeneratorCloses the serializer and the underlying output stream or writer, and releases any memory associated with it.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classJsonGenerator- Throws:
IOException
-
getFactory
Description copied from class:JsonGeneratorReturns the JSON factory from which this generator was created.- Specified by:
getFactoryin classJsonGenerator
-
writeBoolean
Description copied from class:JsonGeneratorWrites a literal JSON boolean value ('true' or 'false').- Specified by:
writeBooleanin classJsonGenerator- Throws:
IOException
-
writeEndArray
Description copied from class:JsonGeneratorWrites a JSON end array character ']'.- Specified by:
writeEndArrayin classJsonGenerator- Throws:
IOException
-
writeEndObject
Description copied from class:JsonGeneratorWrites a JSON end object character '}'.- Specified by:
writeEndObjectin classJsonGenerator- Throws:
IOException
-
writeFieldName
Description copied from class:JsonGeneratorWrites a JSON quoted field name.- Specified by:
writeFieldNamein classJsonGenerator- Throws:
IOException
-
writeNull
Description copied from class:JsonGeneratorWrites a literal JSON null value.- Specified by:
writeNullin classJsonGenerator- Throws:
IOException
-
writeNumber
Description copied from class:JsonGeneratorWrites a JSON int value.- Specified by:
writeNumberin classJsonGenerator- Throws:
IOException
-
writeNumber
Description copied from class:JsonGeneratorWrites a JSON long value.- Specified by:
writeNumberin classJsonGenerator- Throws:
IOException
-
writeNumber
Description copied from class:JsonGeneratorWrites a JSON big integer value.- Specified by:
writeNumberin classJsonGenerator- Throws:
IOException
-
writeNumber
Description copied from class:JsonGeneratorWrites a JSON double value.- Specified by:
writeNumberin classJsonGenerator- Throws:
IOException
-
writeNumber
Description copied from class:JsonGeneratorWrites a JSON float value.- Specified by:
writeNumberin classJsonGenerator- Throws:
IOException
-
writeNumber
Description copied from class:JsonGeneratorWrites a JSON big decimal value.- Specified by:
writeNumberin classJsonGenerator- Throws:
IOException
-
writeNumber
Description copied from class:JsonGeneratorWrites a JSON numeric value that has already been encoded properly.- Specified by:
writeNumberin classJsonGenerator- Throws:
IOException
-
writeStartArray
Description copied from class:JsonGeneratorWrites a JSON start array character '['.- Specified by:
writeStartArrayin classJsonGenerator- Throws:
IOException
-
writeStartObject
Description copied from class:JsonGeneratorWrites a JSON start object character '{'.- Specified by:
writeStartObjectin classJsonGenerator- Throws:
IOException
-
writeString
Description copied from class:JsonGeneratorWrites a JSON quoted string value.- Specified by:
writeStringin classJsonGenerator- Throws:
IOException
-
enablePrettyPrint
Description copied from class:JsonGeneratorRequests 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:
enablePrettyPrintin classJsonGenerator- Throws:
IOException- possible I/O exception (unused in default implementation)
-