Top Description Constructors Methods
tools.jackson.core

public abstract Class JsonGenerator

extends Object
implements Closeable, Flushable, Versioned
Class Inheritance
All Implemented Interfaces
tools.jackson.core.Versioned, java.io.Flushable, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
tools.jackson.core.base.GeneratorBase, tools.jackson.core.util.JsonGeneratorDelegate
Imports
java.io.*, java.math.BigDecimal, .BigInteger, java.util.Objects, tools.jackson.core.JsonParser.NumberType, tools.jackson.core.exc.JacksonIOException, .StreamReadException, .StreamWriteException, tools.jackson.core.io.CharacterEscapes, tools.jackson.core.type.WritableTypeId, .WritableTypeId.Inclusion, tools.jackson.core.util.JacksonFeatureSet

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

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected StreamWriteException
protected StreamWriteException
protected StreamWriteException
protected StreamWriteException
protected void
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 <
Bogus type parameter to "return anything" so that compiler won't complain when chaining calls
T
>
T

Returns:

Does not return at all as exception is always thrown, but nominally returns "anything"
_reportArgumentError
(String
Message to construct exception with
msg
)

Helper method used for constructing and throwing StreamWriteException with given message, in cases where argument(s) used for a call (usually one of writeXxx() methods) is invalid.

protected <
Bogus type parameter to "return anything" so that compiler won't complain when chaining calls
T
>
T

Returns:

Does not return at all as exception is always thrown, but nominally returns "anything"
_reportError
(String
Message to construct exception with
msg
)

Helper method used for constructing and throwing StreamWriteException with given message.

protected <T> T
protected <T> T
protected final void
_verifyOffsets(int arrayLength, int offset, int length)

protected JacksonException
protected boolean

Returns:

True if start of an object has been written, False otherwise.
_writeTypePrefixUsingNative
(WritableTypeId typeIdDef)

Writes a native type id (when supported by format).

protected boolean

Returns:

True if start of an object has been written, false otherwise.
_writeTypePrefixUsingWrapper
(WritableTypeId typeIdDef)

Writes a wrapper for the type id if necessary.

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

Helper method, usually equivalent to: getOutputContext().assignCurrentValue(v); used to assign "current value" for the current context of this generator.

public boolean

Returns:

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

Introspection method to call to check whether it is ok to omit writing of Object properties 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 abstract JsonGenerator

Returns:

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

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

public void
copyCurrentEvent(JsonParser
Parser that points to the event 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 the event 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 void
copyCurrentStructureExact(JsonParser
Parser that points to the value to copy
p
)

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

public abstract Object

Returns:

"Current value" for the current context this generator has
currentValue
()

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

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

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 this generator is configured to use, if any; null if none
getCharacterEscapes
()

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

public int

Returns:

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

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

public PrettyPrinter

Returns:

Pretty printer used by this generator, if any; null if none
getPrettyPrinter
()

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

public FormatSchema

Returns:

FormatSchema this generator is configured to use, if any; null if none
getSchema
()

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

public abstract boolean

Returns:

True if this generator has specified capability; false if not
has
(StreamWriteCapability
Capability to check
capability
)

Accessor for checking whether this generator has specified capability.

public abstract boolean

Returns:

True if this generator has been closed; false if not
isClosed
()

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

public abstract boolean

Returns:

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

Method for checking whether given feature is enabled.

public abstract ObjectWriteContext

Returns:

Object write context (ObjectWriteContext) associated with this generator
objectWriteContext
()

Accessor for context object provided by higher-level databinding functionality (or, in some cases, simple placeholder of the same) that allows some level of interaction including ability to trigger serialization of Object values through generator instance.

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 JacksonFeatureSet<StreamWriteCapability>

Returns:

Set of read capabilities for content to generate via this generator
streamWriteCapabilities
()

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

public StreamWriteConstraints

Returns:

Constraints used for this generator
streamWriteConstraints
()

Get the constraints to apply when performing streaming writes.

public abstract TokenStreamContext

Returns:

Stream output context (TokenStreamContext) associated with this generator
streamWriteContext
()

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

public abstract int

Returns:

Bit mask that defines current states of all standard StreamWriteFeatures.
streamWriteFeatures
()

Bulk access method for getting state of all standard (format-agnostic) StreamWriteFeatures.

public abstract int

Returns:

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

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 Object

Returns:

Output target this generator was configured with
streamWriteOutputTarget
()

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

public abstract Version
version()

Redeclares tools.jackson.core.Versioned.version.

Accessor for finding out version of the bundle that provided this generator instance.

public JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 final JsonGenerator

Returns:

This generator, to allow call chaining
writeArrayPropertyStart
(String
Name of the Array property to write
propertyName
)

Convenience method for outputting an Object property (that will contain a JSON Array value), and the START_ARRAY marker.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 final JsonGenerator

Returns:

This generator, to allow call chaining
writeBinaryProperty
(String
Name of Object Property to write
propertyName
,
byte[]
Binary value of the property to write
data
)

Convenience method for outputting an Object property that contains specified data in base64-encoded form.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeBoolean
(boolean
Boolean value to write
state
)

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

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeBooleanProperty
(String
Name of Object Property to write
propertyName
,
boolean
Boolean value of the property to write
value
)

Convenience method for outputting an Object property that has a boolean value.

public JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
writeEndArray
()

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

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeEndObject
()

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

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeName
(String
Name of the Object Property to write
name
)

Method for writing an Object Property 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 JsonGenerator

Returns:

This generator, to allow call chaining
writeName
(SerializableString
Pre-encoded name of the Object Property to write
name
)

Method similar to writeName(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 JsonGenerator

Returns:

This generator, to allow call chaining
writeNull
()

Method for outputting literal JSON null value.

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeNullProperty
(String
Name of the null-valued property to write
propertyName
)

Convenience method for outputting an Object property that has JSON literal value null.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeNumber
(short
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeNumber
(int
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeNumber
(long
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeNumber
(BigInteger
Number value to write
v
)

Method for outputting given value as JSON number.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeNumber
(double
Number value to write
v
)

Method for outputting indicate JSON numeric value.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeNumber
(float
Number value to write
v
)

Method for outputting indicate JSON numeric value.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeNumber
(BigDecimal
Number value to write
v
)

Method for outputting indicate JSON numeric value.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 final JsonGenerator

Returns:

This generator, to allow call chaining
writeNumberProperty
(String
Name of the property to write
propertyName
,
short
Numeric value of the property to write
value
)

Convenience method for outputting an Object property that has the specified numeric value.

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeNumberProperty
(String
Name of the property to write
propertyName
,
int
Numeric value of the property to write
value
)

Convenience method for outputting an Object property that has the specified numeric value.

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeNumberProperty
(String
Name of the property to write
propertyName
,
long
Numeric value of the property to write
value
)

Convenience method for outputting an Object property that has the specified numeric value.

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeNumberProperty
(String
Name of the property to write
propertyName
,
BigInteger
Numeric value of the property to write
value
)

Convenience method for outputting an Object property that has the specified numeric value.

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeNumberProperty
(String
Name of the property to write
propertyName
,
float
Numeric value of the property to write
value
)

Convenience method for outputting an Object property that has the specified numeric value.

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeNumberProperty
(String
Name of the property to write
propertyName
,
double
Numeric value of the property to write
value
)

Convenience method for outputting an Object property that has the specified numeric value.

public final JsonGenerator

Returns:

This generator, to allow call chaining
writeNumberProperty
(String
Name of the property to write
propertyName
,
BigDecimal
Numeric value of the property to write
value
)

Convenience method for outputting an Object property that has the specified numeric value.

public JsonGenerator

Returns:

This generator, to allow call chaining
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 final JsonGenerator

Returns:

This generator, to allow call chaining
writeObjectPropertyStart
(String
Name of the Object property to write
propertyName
)

Convenience method for outputting an Object property (that will contain an Object value), and the START_OBJECT marker.

public JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
writeOmittedProperty
(String
Name of the property that is being omitted
propertyName
)

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

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writePOJO
(Object
Java Object (POJO) value to write
pojo
)

Method for writing given Java object (POJO) as tokens into stream this generator manages; serialization must be a valid JSON Value (Object, Array, null, Number, String or Boolean).

public final JsonGenerator

Returns:

This generator, to allow call chaining
writePOJOProperty
(String
Name of the property to write
propertyName
,
Object
POJO value of the property to write
pojo
)

Convenience method for outputting am Object property that has contents of specific Java object (POJO) as its value.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writePropertyId
(long
Property key id to write
id
)

Alternative to writeName(String) that may be used in cases where Object Property key is of numeric type; usually where underlying format supports such notion (some binary formats do, unlike JSON).

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
writeRaw
(char[]
Buffer that has contents to include as-is in output
buffer
,
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator
writeRawValue(String text, int offset, int len)

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

public JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeStartArray
(Object
Java Object that Array being written represents, if any (or null if not known or not applicable)
currentValue
)

Method for writing start marker of an Array value, similar to writeStartArray(), but also specifying what is the Java object that the Array Object being written represents (if any); null may be passed if not known or not applicable.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeStartArray
(Object
Java Object that Array being written represents, if any (or null if not known or not applicable)
currentValue
,
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 what is the Java object that the Array Object being written represents (if any) and how many elements will be written for the array before calling writeEndArray().

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeStartObject
()

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

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeStartObject
(Object
Java Object that Object being written represents, if any (or null if not known or not applicable)
currentValue
)

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

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeStartObject
(Object
Object value to be written (assigned as "current value" for the Object context that gets 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 JsonGenerator

Returns:

This generator, to allow call chaining
writeString
(String
String value to write
value
)

Method for outputting a String value.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
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 JsonGenerator

Returns:

This generator, to allow call chaining
writeString
(SerializableString
Pre-encoded String value to write
value
)

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 final JsonGenerator

Returns:

This generator, to allow call chaining
writeStringProperty
(String
Name of the property to write
propertyName
,
String
String value of the property to write
value
)

Convenience method for outputting an Object property that has a String value.

public abstract JsonGenerator

Returns:

This generator, to allow call chaining
writeTree
(TreeNode
TreeNode to write
rootNode
)

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

public JsonGenerator

Returns:

This generator, to allow call chaining
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
public abstract JsonGenerator

Returns:

This generator, to allow call chaining
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