Package com.google.api.client.json
Class JsonGenerator
java.lang.Object
com.google.api.client.json.JsonGenerator
- Direct Known Subclasses:
GsonGenerator
,JacksonGenerator
,JacksonGenerator
,MockJsonGenerator
Abstract low-level JSON serializer.
Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily thread-safe.
- Since:
- 1.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
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).abstract void
flush()
Flushes any buffered content to the underlying output stream or writer.abstract JsonFactory
Returns the JSON factory from which this generator was created.private void
final void
Serializes the given JSON value object, or ifvalue
isnull
it does no serialization.abstract void
writeBoolean
(boolean state) Writes a literal JSON boolean value ('true' or 'false').abstract void
Writes a JSON end array character ']'.abstract void
Writes a JSON end object character '}'.abstract void
writeFieldName
(String name) Writes a JSON quoted field name.abstract void
Writes a literal JSON null value.abstract void
writeNumber
(double v) Writes a JSON double value.abstract void
writeNumber
(float v) Writes a JSON float value.abstract void
writeNumber
(int v) Writes a JSON int value.abstract void
writeNumber
(long v) Writes a JSON long value.abstract void
writeNumber
(String encodedValue) Writes a JSON numeric value that has already been encoded properly.abstract void
Writes a JSON big decimal value.abstract void
Writes a JSON big integer value.abstract void
Writes a JSON start array character '['.abstract void
Writes a JSON start object character '{'.abstract void
writeString
(String value) Writes a JSON quoted string value.
-
Constructor Details
-
JsonGenerator
public JsonGenerator()
-
-
Method Details
-
getFactory
Returns the JSON factory from which this generator was created. -
flush
Flushes any buffered content to the underlying output stream or writer.- Throws:
IOException
-
close
Closes the serializer and the underlying output stream or writer, and releases any memory associated with it.- Throws:
IOException
-
writeStartArray
Writes a JSON start array character '['.- Throws:
IOException
-
writeEndArray
Writes a JSON end array character ']'.- Throws:
IOException
-
writeStartObject
Writes a JSON start object character '{'.- Throws:
IOException
-
writeEndObject
Writes a JSON end object character '}'.- Throws:
IOException
-
writeFieldName
Writes a JSON quoted field name.- Throws:
IOException
-
writeNull
Writes a literal JSON null value.- Throws:
IOException
-
writeString
Writes a JSON quoted string value.- Throws:
IOException
-
writeBoolean
Writes a literal JSON boolean value ('true' or 'false').- Throws:
IOException
-
writeNumber
Writes a JSON int value.- Throws:
IOException
-
writeNumber
Writes a JSON long value.- Throws:
IOException
-
writeNumber
Writes a JSON big integer value.- Throws:
IOException
-
writeNumber
Writes a JSON float value.- Throws:
IOException
-
writeNumber
Writes a JSON double value.- Throws:
IOException
-
writeNumber
Writes a JSON big decimal value.- Throws:
IOException
-
writeNumber
Writes a JSON numeric value that has already been encoded properly.- Throws:
IOException
-
serialize
Serializes the given JSON value object, or ifvalue
isnull
it does no serialization.- Throws:
IOException
-
serialize
- Throws:
IOException
-
enablePrettyPrint
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.
- Throws:
IOException
- possible I/O exception (unused in default implementation)- Since:
- 1.6
-