Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.core

public abstract Class JsonGenerator

extends Object
implements Closeable, Flushable, Versioned
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.Versioned, java.io.Flushable, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
com.fasterxml.jackson.core.base.GeneratorBase, com.fasterxml.jackson.core.util.JsonGeneratorDelegate
Imports
java.io.*, java.math.BigDecimal, .BigInteger, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, .AtomicLong, com.fasterxml.jackson.core.JsonParser.NumberType, com.fasterxml.jackson.core.io.CharacterEscapes, com.fasterxml.jackson.core.type.WritableTypeId, .WritableTypeId.Inclusion, com.fasterxml.jackson.core.util.JacksonFeatureSet, .VersionUtil

Base class that defines public API for writing JSON content. Instances are created using factory methods of a JsonFactory instance.
Author
Tatu Saloranta

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
JsonGenerator.Feature

Enumeration that defines all togglable features for generators.

Field Summary

Modifier and TypeField and Description
protected PrettyPrinter
_cfgPrettyPrinter

Object that handles pretty-printing (usually additional white space to make results more human-readable) during output.

protected static final JacksonFeatureSet<StreamWriteCapability>
DEFAULT_BINARY_WRITE_CAPABILITIES

Default set of StreamWriteCapabilityies for typical binary formats, to use either as-is, or as a base with possible differences.

protected static final JacksonFeatureSet<StreamWriteCapability>
DEFAULT_TEXTUAL_WRITE_CAPABILITIES

Default set of StreamWriteCapabilityies for typical textual formats, to use either as-is, or as a base with possible differences.

protected static final JacksonFeatureSet<StreamWriteCapability>
DEFAULT_WRITE_CAPABILITIES

Default set of StreamWriteCapabilityies that may be used as basis for format-specific readers (or as bogus instance if non-null set needs to be passed).

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
_copyCurrentFloatValue(JsonParser
Parser that points to the value to copy
p
)

Method for copying current JsonToken#VALUE_NUMBER_FLOAT value; overridable by format backend implementations.

protected void
_copyCurrentFloatValueExact(JsonParser
Parser that points to the value to copy
p
)

Method for copying current JsonToken#VALUE_NUMBER_FLOAT value; overridable by format backend implementations.

protected void
_copyCurrentIntValue(JsonParser
Parser that points to the value to copy
p
)

Method for copying current JsonToken#VALUE_NUMBER_FLOAT value; overridable by format backend implementations.

protected void
_copyCurrentStringValue(JsonParser
Parser that points to the value to copy
p
)

Method for copying current JsonToken#VALUE_STRING value; overridable by format backend implementations.

protected void
_reportError(String
Exception message to use
msg
)

Helper method used for constructing and throwing JsonGenerationException with given base message.

protected void
protected final void
protected final void
_verifyOffsets(int arrayLength, int offset, int length)

protected void
_writeSimpleObject(Object
Value to write
value
)

Helper method to try to call appropriate write method for given untyped Object.

public void
assignCurrentValue(Object
Current value to assign for the current context of this generator
v
)

Helper method, usually equivalent to: getOutputContext().setCurrentValue(v);

public boolean

Returns:

True if this generator is allowed to only write values of some Object fields and omit the rest; false if not
canOmitFields
()

Introspection method to call to check whether it is ok to omit writing of Object fields or not.

public boolean

Returns:

True if this generator can use given schema; false if not
canUseSchema
(FormatSchema
Schema to check
schema
)

Method that can be used to verify that given schema can be used with this generator (using setSchema).

public boolean

Returns:

True if this generator is capable of writing "raw" Binary Content (this is typically determined by capabilities of the underlying format); false if not
canWriteBinaryNatively
()

Introspection method that may be called to see if the underlying data format supports "native" binary data; that is, an efficient output of binary content without encoding.

public boolean

Returns:

True if this generator is capable of writing "formatted" numbers (and if so, need to be passed using writeNumber(String), that is, passed as String); false if not
canWriteFormattedNumbers
()

Introspection method to call to check whether it is possible to write numbers using writeNumber(java.lang.String) using possible custom format, or not.

public boolean

Returns:

True if this generator is capable of writing "native" Object Ids (which is typically determined by capabilities of the underlying format), false if not
canWriteObjectId
()

Introspection method that may be called to see if the underlying data format supports some kind of Object Ids natively (many do not; for example, JSON doesn't).

public boolean

Returns:

True if this generator is capable of writing "native" Type Ids (which is typically determined by capabilities of the underlying format), false if not
canWriteTypeId
()

Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't).

public abstract void
close()

Redeclares java.io.Closeable.close.

Method called to close this generator, so that no more content can be written.
public final JsonGenerator

Returns:

This generator, to allow call chaining
configure
(JsonGenerator.Feature
Feature to enable or disable
f
,
boolean
Whether to enable (true) or disable (false) feature
state
)

Method for enabling or disabling specified feature: check Feature for list of available features.

public void
copyCurrentEvent(JsonParser
Parser that points to event (token) to copy
p
)

Method for copying contents of the current event that the given parser instance points to.

public void
copyCurrentEventExact(JsonParser
Parser that points to event (token) to copy
p
)

Same as copyCurrentEvent with the exception that copying of numeric values tries to avoid any conversion losses; in particular for floating-point numbers.

public void
copyCurrentStructure(JsonParser
Parser that points to the value to copy
p
)

Method for copying contents of the current event and following events that it encloses the given parser instance points to.

public Object

Returns:

"Current value" associated with the current context (state) of this generator
currentValue
()

Helper method, usually equivalent to: getOutputContext().getCurrentValue();

Note that "current value" is NOT populated (or used) by Streaming parser or generators; it is only used by higher-level data-binding functionality.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
disable
(JsonGenerator.Feature
Feature to disable
f
)

Method for disabling specified feature (check Feature for list of features)

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
enable
(JsonGenerator.Feature
Feature to enable
f
)

Method for enabling specified generator feature: check Feature for list of available features.

public abstract void
flush()

Redeclares java.io.Flushable.flush.

Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well.
public CharacterEscapes

Returns:

CharacterEscapes configured for this generator, if any; null if none
getCharacterEscapes
()

Method for accessing custom escapes factory uses for JsonGenerators it creates.

public abstract ObjectCodec

Returns:

Codec assigned to this generator, if any; null if none
getCodec
()

Method for accessing the object used for writing Java object as JSON content (using method writeObject).

public Object

Returns:

Location of the last processed input unit (byte or character)
getCurrentValue
()

Alias for currentValue(), to be deprecated in later Jackson 2.x versions (and removed from Jackson 3.0).

public abstract int

Returns:

Bit mask that defines current states of all standard JsonGenerator.Features.
getFeatureMask
()

Bulk access method for getting state of all standard (non-dataformat-specific) JsonGenerator.Features.

public int

Returns:

Bit mask that defines current states of all standard FormatFeatures.
getFormatFeatures
()

Bulk access method for getting state of all FormatFeatures, format-specific on/off configuration settings.

public int

Returns:

Currently active limitation for highest non-escaped character, if defined; or 0 to indicate no additional escaping is performed.
getHighestEscapedChar
()

Accessor method for testing what is the highest unescaped character configured for this generator.

public int

Returns:

Amount of content buffered in internal units, if amount known and accessible; -1 if not accessible.
getOutputBuffered
()

Method for verifying amount of content that is buffered by generator but not yet flushed to the underlying target (stream, writer), in units (byte, char) that the generator implementation uses for buffering; or -1 if this information is not available.

public abstract JsonStreamContext

Returns:

Stream output context (JsonStreamContext) associated with this generator
getOutputContext
()

Accessor for context object that provides information about low-level logical position withing output token stream.

public Object

Returns:

Output target this generator was configured with
getOutputTarget
()

Method that can be used to get access to object that is used as target for generated output; this is usually either OutputStream or Writer, depending on what generator was constructed with.

public PrettyPrinter

Returns:

PrettyPrinter configured for this generator, if any; null if none
getPrettyPrinter
()

Accessor for checking whether this generator has a configured PrettyPrinter; returns it if so, null if none configured.

public FormatSchema

Returns:

Schema in use by this generator, if any; null if none
getSchema
()

Method for accessing Schema that this generator uses, if any; null if none.

public JacksonFeatureSet<StreamWriteCapability>

Returns:

Set of write capabilities for content written using this generator
getWriteCapabilities
()

Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly).

public abstract boolean

Returns:

True if this generator instance has been closed
isClosed
()

Method that can be called to determine whether this generator is closed or not.

public abstract boolean

Returns:

True if specified feature is enabled; false if not
isEnabled
(JsonGenerator.Feature
Feature to check
f
)

Method for checking whether given feature is enabled.

public boolean

Returns:

True if specified feature is enabled; false if not
isEnabled
(StreamWriteFeature
Feature to check
f
)

Method for checking whether given feature is enabled.

public JsonGenerator

Returns:

This generator, to allow call chaining
overrideFormatFeatures
(int
Bit mask of set/clear state for features to change
values
,
int
Bit mask of features to change
mask
)

Bulk set method for (re)setting states of FormatFeatures, by specifying values (set / clear) along with a mask, to determine which features to change, if any.

public JsonGenerator

Returns:

This generator, to allow call chaining
overrideStdFeatures
(int
Bit mask of set/clear state for features to change
values
,
int
Bit mask of features to change
mask
)

Bulk set method for (re)setting states of features specified by mask.

public JsonGenerator

Returns:

This generator, to allow call chaining
setCharacterEscapes
(CharacterEscapes
CharacterEscapes to configure this generator to use, if any; null if none
esc
)

Method for defining custom escapes factory uses for JsonGenerators it creates.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
setCodec
(ObjectCodec
Codec to assign, if any; null if none
oc
)

Method that can be called to set or reset the object to use for writing Java objects as JsonContent (using method writeObject).

public void
setCurrentValue(Object
Current value to assign for the current context of this generator
v
)

Alias for assignCurrentValue, to be deprecated in later Jackson 2.x versions (and removed from Jackson 3.0).

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
setFeatureMask
(int
Bitmask that defines which Features are enabled and which disabled
values
)

Deprecated Since 2.7, use overrideStdFeatures(int, int) instead -- remove from 2.9
Bulk set method for (re)setting states of all standard Features
public JsonGenerator

Returns:

This generator, to allow call chaining
setHighestNonEscapedChar
(int
Either -1 to indicate that no additional escaping is to be done; or highest code point not to escape (meaning higher ones will be), if positive value.
charCode
)

Method that can be called to request that generator escapes all character codes above specified code point (if positive value); or, to not escape any characters except for ones that must be escaped for the data format (if -1).

public JsonGenerator

Returns:

This generator, to allow call chaining
setPrettyPrinter
(PrettyPrinter
PrettyPrinter to assign, if any; null if none
pp
)

Method for setting a custom pretty printer, which is usually used to add indentation for improved human readability.

public JsonGenerator

Returns:

This generator, to allow call chaining
setRootValueSeparator
(SerializableString
Separator to use, if any; null means that no separator is automatically added
sep
)

Method that allows overriding String used for separating root-level JSON values (default is single space character)

Default implementation throws UnsupportedOperationException.

public void
setSchema(FormatSchema
Schema to use
schema
)

Method to call to make this generator use specified schema.

public StreamWriteConstraints
streamWriteConstraints()

Get the constraints to apply when performing streaming writes.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
useDefaultPrettyPrinter
()

Convenience method for enabling pretty-printing using the default pretty printer (com.fasterxml.jackson.core.util.DefaultPrettyPrinter).

public abstract Version

Returns:

Version of this generator (derived from version declared for jackson-core jar that contains the class
version
()

Redeclares com.fasterxml.jackson.core.Versioned.version.

Accessor for finding out version of the bundle that provided this generator instance.
public void
writeArray(int[]
Array that contains values to write
array
,
int
Offset of the first element to write, within array
offset
,
int
Number of elements in array to write, from `offset` to `offset + len - 1`
length
)

Value write method that can be called to write a single array (sequence of JsonToken#START_ARRAY, zero or more JsonToken#VALUE_NUMBER_INT, JsonToken#END_ARRAY)

public void
writeArray(long[]
Array that contains values to write
array
,
int
Offset of the first element to write, within array
offset
,
int
Number of elements in array to write, from `offset` to `offset + len - 1`
length
)

Value write method that can be called to write a single array (sequence of JsonToken#START_ARRAY, zero or more JsonToken#VALUE_NUMBER_INT, JsonToken#END_ARRAY)

public void
writeArray(double[]
Array that contains values to write
array
,
int
Offset of the first element to write, within array
offset
,
int
Number of elements in array to write, from `offset` to `offset + len - 1`
length
)

Value write method that can be called to write a single array (sequence of JsonToken#START_ARRAY, zero or more JsonToken#VALUE_NUMBER_FLOAT, JsonToken#END_ARRAY)

public void
writeArray(String[]
Array that contains values to write
array
,
int
Offset of the first element to write, within array
offset
,
int
Number of elements in array to write, from `offset` to `offset + len - 1`
length
)

Value write method that can be called to write a single array (sequence of JsonToken#START_ARRAY, zero or more JsonToken#VALUE_STRING, JsonToken#END_ARRAY)

public void
writeArrayFieldStart(String
Name of the field to write
fieldName
)

Convenience method for outputting a field entry ("member") (that will contain a JSON Array value), and the START_ARRAY marker.

public abstract void
writeBinary(Base64Variant
Base64 variant to use: defines details such as whether padding is used (and if so, using which character); what is the maximum line length before adding linefeed, and also the underlying alphabet to use.
bv
,
byte[]
Buffer that contains binary data to write
data
,
int
Offset in data of the first byte of data to write
offset
,
int
Length of data to write
len
)

Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes).

public void
writeBinary(byte[]
Buffer that contains binary data to write
data
,
int
Offset in data of the first byte of data to write
offset
,
int
Length of data to write
len
)

Similar to writeBinary(Base64Variant, byte[], int, int), but default to using the Jackson default Base64 variant (which is Base64Variants#MIME_NO_LINEFEEDS).

public void
writeBinary(byte[]
Buffer that contains binary data to write
data
)

Similar to writeBinary(Base64Variant, byte[], int, int), but assumes default to using the Jackson default Base64 variant (which is Base64Variants#MIME_NO_LINEFEEDS).

public int

Returns:

Number of bytes actually written
writeBinary
(InputStream
InputStream to use for reading binary data to write. Will not be closed after successful write operation
data
,
int
(optional) number of bytes that will be available; or -1 to be indicate it is not known. Note that implementations need not support cases where length is not known in advance; this depends on underlying data format: JSON output does NOT require length, other formats may
dataLength
)

Similar to writeBinary(Base64Variant, InputStream, int), but assumes default to using the Jackson default Base64 variant (which is Base64Variants#MIME_NO_LINEFEEDS).

public abstract int

Returns:

Number of bytes read from data and written as binary payload
writeBinary
(Base64Variant
Base64 variant to use
bv
,
InputStream
InputStream to use for reading binary data to write. Will not be closed after successful write operation
data
,
int
(optional) number of bytes that will be available; or -1 to be indicate it is not known. If a positive length is given, data MUST provide at least that many bytes: if not, an exception will be thrown. Note that implementations need not support cases where length is not known in advance; this depends on underlying data format: JSON output does NOT require length, other formats may.
dataLength
)

Method similar to writeBinary(Base64Variant, byte[], int, int), but where input is provided through a stream, allowing for incremental writes without holding the whole input in memory.

public void
writeBinaryField(String
Name of the field to write
fieldName
,
byte[]
Binary data for the field to write
data
)

Convenience method for outputting a field entry ("member") that contains specified data in base64-encoded form.

public abstract void
writeBoolean(boolean
Boolean value to write
state
)

Method for outputting literal JSON boolean value (one of Strings 'true' and 'false').

public void
writeBooleanField(String
Name of the field to write
fieldName
,
boolean
Boolean value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has a boolean value.

public void
writeEmbeddedObject(Object
Native format-specific value to write
object
)

Method that can be called on backends that support passing opaque native values that some data formats support; not used with JSON backend, more common with binary formats.

public abstract void
writeEndArray()

Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled).

public abstract void
writeEndObject()

Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled).

public void
writeFieldId(long
Field id to write
id
)

Alternative to writeFieldName(String) that may be used in cases where property key is of numeric type; either where underlying format supports such notion (some binary formats do, unlike JSON), or for convenient conversion into String presentation.

public abstract void
writeFieldName(String
Field name to write
name
)

Method for writing a field name (JSON String surrounded by double quotes: syntactically identical to a JSON String value), possibly decorated by white space if pretty-printing is enabled.

public abstract void
writeFieldName(SerializableString
Field name to write
name
)

Method similar to writeFieldName(String), main difference being that it may perform better as some of processing (such as quoting of certain characters, or encoding into external encoding if supported by generator) can be done just once and reused for later calls.

public abstract void
writeNull()

Method for outputting literal JSON null value.

public void
writeNullField(String
Name of the field to write
fieldName
)

Convenience method for outputting a field entry ("member") that has JSON literal value null.

public void
writeNumber(short
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract void
writeNumber(int
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract void
writeNumber(long
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract void
writeNumber(BigInteger
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract void
writeNumber(double
Number value to write
v
)

Method for outputting indicate JSON numeric value.

public abstract void
writeNumber(float
Number value to write
v
)

Method for outputting indicate JSON numeric value.

public abstract void
writeNumber(BigDecimal
Number value to write
v
)

Method for outputting indicate JSON numeric value.

public abstract void
writeNumber(String
Textual (possibly format) number representation to write
encodedValue
)

Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types.

public void
writeNumber(char[]
Buffer that contains the textual number representation to write
encodedValueBuffer
,
int
Offset of the first character of value to write
offset
,
int
Length of the value (in characters) to write
len
)

Overloaded version of writeNumber(String) with same semantics but possibly more efficient operation.

public void
writeNumberField(String
Name of the field to write
fieldName
,
short
Numeric value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has the specified numeric value.

public void
writeNumberField(String
Name of the field to write
fieldName
,
int
Numeric value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has the specified numeric value.

public void
writeNumberField(String
Name of the field to write
fieldName
,
long
Numeric value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has the specified numeric value.

public void
writeNumberField(String
Name of the field to write
fieldName
,
BigInteger
Numeric value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has the specified numeric value.

public void
writeNumberField(String
Name of the field to write
fieldName
,
float
Numeric value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has the specified numeric value.

public void
writeNumberField(String
Name of the field to write
fieldName
,
double
Numeric value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has the specified numeric value.

public void
writeNumberField(String
Name of the field to write
fieldName
,
BigDecimal
Numeric value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has the specified numeric value.

public abstract void
writeObject(Object
Java value (usually POJO) to write
pojo
)

Older alias for writePOJO(Object)

public void
writeObjectField(String
Name of the field to write
fieldName
,
Object
POJO value of the field to write
pojo
)

Older alias for writePOJOField

public void
writeObjectFieldStart(String
Name of the field to write
fieldName
)

Convenience method for outputting a field entry ("member") (that will contain an Object value), and the START_OBJECT marker.

public void
writeObjectId(Object
Native Object Id to write
id
)

Method that can be called to output so-called native Object Id. Note that it may only be called after ensuring this is legal (with canWriteObjectId()), as not all data formats have native type id support; and some may only allow them in certain positions or locations.

public void
writeObjectRef(Object
Referenced value, for which Object Id is expected to be written
referenced
)

Method that can be called to output references to native Object Ids.

public void
writeOmittedField(String
Name of the field omitted
fieldName
)

Method called to indicate that a property in this position was skipped.

public void
writePOJO(Object
Java value (usually POJO) to write
pojo
)

Method for writing given Java object (POJO) as JSON.

public void
writePOJOField(String
Name of the field to write
fieldName
,
Object
POJO value of the field to write
pojo
)

Convenience method for outputting a field entry ("member") that has contents of specific Java object as its value.

public abstract void
writeRaw(String
Textual contents to include as-is in output.
text
)

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public abstract void
writeRaw(String
String that has contents to include as-is in output
text
,
int
Offset within text of the first character to output
offset
,
int
Length of content (from text, starting at offset offset) to output
len
)

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public abstract void
writeRaw(char[]
Buffer that has contents to include as-is in output
text
,
int
Offset within text of the first character to output
offset
,
int
Length of content (from text, starting at offset offset) to output
len
)

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public abstract void
writeRaw(char
Character to included in output
c
)

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public void
writeRaw(SerializableString
Pre-encoded textual contents to included in output
raw
)

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public abstract void
writeRawUTF8String(byte[]
Buffer that contains String value to write
buffer
,
int
Offset in buffer of the first byte of String value to write
offset
,
int
Length of the String value (in characters) to write
len
)

Method similar to writeString(String) but that takes as its input a UTF-8 encoded String that is to be output as-is, without additional escaping (type of which depends on data format; backslashes for JSON).

public abstract void
writeRawValue(String
Textual contents to included in output
text
)

Method that will force generator to copy input text verbatim without any modifications, but assuming it must constitute a single legal JSON value (number, string, boolean, null, Array or List).

public abstract void
writeRawValue(String text, int offset, int len)

public abstract void
writeRawValue(char[] text, int offset, int len)

public void
writeRawValue(SerializableString
Pre-encoded textual contents to included in output
raw
)

Method similar to writeRawValue(String), but potentially more efficient as it may be able to use pre-encoded content (similar to writeRaw(SerializableString).

public abstract void
writeStartArray()

Method for writing starting marker of a Array value (for JSON this is character '['; plus possible white space decoration if pretty-printing is enabled).

public void
writeStartArray(int
Number of elements this array will have: actual number of values written (before matching call to writeEndArray() MUST match; generator MAY verify this is the case (and SHOULD if format itself encodes length)
size
)

Deprecated Since 2.12 Use writeStartArray(Object, int) instead
Method for writing start marker of an Array value, similar to writeStartArray(), but also specifying how many elements will be written for the array before calling writeEndArray().
public void
writeStartArray(Object
"Current value" to assign for the Array context being created
forValue
)

Method for writing start marker of an Array value, similar to writeStartArray(), but also specifying the "current value" to assign to the new Array context being created.

public void
writeStartArray(Object
"Current value" to assign for the Array context being created
forValue
,
int
Number of elements this Array will have: actual number of values written (before matching call to writeEndArray() MUST match; generator MAY verify this is the case (and SHOULD if format itself encodes length)
size
)

Method for writing start marker of an Array value, similar to writeStartArray(), but also specifying the "current value" to assign to the new Array context being created as well as how many elements will be written for the array before calling writeEndArray().

public abstract void
writeStartObject()

Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled).

public void
writeStartObject(Object
"Current value" to assign for the Object context being created
forValue
)

Method for writing starting marker of an Object value to represent the given Java Object value.

public void
writeStartObject(Object
"Current value" to assign for the Object context being created
forValue
,
int
Number of key/value pairs this Object will have: actual number of entries written (before matching call to writeEndObject() MUST match; generator MAY verify this is the case (and SHOULD if format itself encodes length)
size
)

Method for writing starting marker of an Object value to represent the given Java Object value.

public abstract void
writeString(String
Text value to write
text
)

Method for outputting a String value.

public void
writeString(Reader
Reader to use for reading Text value to write
reader
,
int
Maximum Length of Text value to read (in chars, non-negative) if known; -1 to indicate "read and write it all"
len
)

Method for outputting a String value.

public abstract void
writeString(char[]
Buffer that contains String value to write
buffer
,
int
Offset in buffer of the first character of String value to write
offset
,
int
Length of the String value (in characters) to write
len
)

Method for outputting a String value.

public abstract void
writeString(SerializableString
Pre-encoded String value to write
text
)

Method similar to writeString(String), but that takes SerializableString which can make this potentially more efficient to call as generator may be able to reuse quoted and/or encoded representation.

public void
writeStringField(String
Name of the field to write
fieldName
,
String
String value of the field to write
value
)

Convenience method for outputting a field entry ("member") that has a String value.

public abstract void
writeTree(TreeNode
TreeNode to write
rootNode
)

Method for writing given JSON tree (expressed as a tree where given JsonNode is the root) using this generator.

public void
writeTypeId(Object
Native Type Id to write
id
)

Method that can be called to output so-called native Type Id. Note that it may only be called after ensuring this is legal (with canWriteTypeId()), as not all data formats have native type id support; and some may only allow them in certain positions or locations.

public WritableTypeId

Returns:

WritableTypeId for caller to retain and pass to matching writeTypeSuffix call
writeTypePrefix
(WritableTypeId
Full Type Id definition
typeIdDef
)

Replacement method for writeTypeId(Object) which is called regardless of whether format has native type ids.

public WritableTypeId

Returns:

Argument typeIdDef, possibly modified
writeTypeSuffix
(WritableTypeId
Value returned by the earlier matching call to writeTypePrefix(WritableTypeId)
typeIdDef
)

Method to call along with writeTypePrefix, but after actual value that has type id has been completely written.

public abstract void
writeUTF8String(byte[]
Buffer that contains String value to write
buffer
,
int
Offset in buffer of the first byte of String value to write
offset
,
int
Length of the String value (in characters) to write
len
)

Method similar to writeString(String) but that takes as its input a UTF-8 encoded String which has not been escaped using whatever escaping scheme data format requires (for JSON that is backslash-escaping for control characters and double-quotes; for other formats something else).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait