Send feedback
Class JsonGenerator (1.43.2)
Stay organized with collections
Save and categorize content based on your preferences.
Version 1.43.2 keyboard_arrow_down
public abstract class JsonGenerator implements Closeable , Flushable
Abstract low-level JSON serializer.
Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily
thread-safe.
Inheritance
Object >
JsonGenerator
Constructors
JsonGenerator()
Methods
close()
public abstract void close ()
Closes the serializer and the underlying output stream or writer, and releases any memory
associated with it.
enablePrettyPrint()
public void 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.
Exceptions
Type
Description
IOException
possible I/O exception (unused in default implementation)
flush()
public abstract void flush ()
Flushes any buffered content to the underlying output stream or writer.
getFactory()
public abstract JsonFactory getFactory ()
Returns the JSON factory from which this generator was created.
serialize(Object value)
public final void serialize ( Object value )
Serializes the given JSON value object, or if value
is null
it does no
serialization.
Parameter
Name
Description
value
Object
writeBoolean(boolean state)
public abstract void writeBoolean ( boolean state )
Writes a literal JSON boolean value ('true' or 'false').
Parameter
Name
Description
state
boolean
writeEndArray()
public abstract void writeEndArray ()
Writes a JSON end array character ']'.
writeEndObject()
public abstract void writeEndObject ()
Writes a JSON end object character '}'.
writeFieldName(String name)
public abstract void writeFieldName ( String name )
Writes a JSON quoted field name.
Parameter
Name
Description
name
String
writeNull()
public abstract void writeNull ()
Writes a literal JSON null value.
writeNumber(double v)
public abstract void writeNumber ( double v )
Writes a JSON double value.
Parameter
Name
Description
v
double
writeNumber(float v)
public abstract void writeNumber ( float v )
Writes a JSON float value.
Parameter
Name
Description
v
float
writeNumber(int v)
public abstract void writeNumber ( int v )
Parameter
Name
Description
v
int
writeNumber(String encodedValue)
public abstract void writeNumber ( String encodedValue )
Writes a JSON numeric value that has already been encoded properly.
Parameter
Name
Description
encodedValue
String
writeNumber(BigDecimal v)
public abstract void writeNumber ( BigDecimal v )
Writes a JSON big decimal value.
writeNumber(BigInteger v)
public abstract void writeNumber ( BigInteger v )
Writes a JSON big integer value.
writeNumber(long v)
public abstract void writeNumber ( long v )
Writes a JSON long value.
Parameter
Name
Description
v
long
writeStartArray()
public abstract void writeStartArray ()
Writes a JSON start array character '['.
writeStartObject()
public abstract void writeStartObject ()
Writes a JSON start object character '{'.
writeString(String value)
public abstract void writeString ( String value )
Writes a JSON quoted string value.
Parameter
Name
Description
value
String
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-12 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-12 UTC."],[],[]]