- All Implemented Interfaces:
tools.jackson.core.Versioned
ObjectMapper
and can be
reused in completely thread-safe manner with no explicit synchronization-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
As a minor optimization, we will make an effort to pre-fetch a serializer, or at least relevantTypeSerializer
, if given enough information. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SerializationConfig
General serialization configuration settingsprotected final tools.jackson.core.TokenStreamFactory
Factory used for constructingJsonGenerator
sprotected final GeneratorSettings
Container for settings that need to be passed toJsonGenerator
constructed for serializing values.protected final ObjectWriter.Prefetch
We may pre-fetch serializer if root type is known (has been explicitly declared), and if so, reuse it afterwards.protected final SerializationContexts
Factory used for constructing per-callSerializationContext
s. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ObjectWriter
(ObjectMapper mapper, SerializationConfig config) Alternative constructor for initial instantiation byObjectMapper
protected
ObjectWriter
(ObjectMapper mapper, SerializationConfig config, tools.jackson.core.FormatSchema s) Alternative constructor for initial instantiation byObjectMapper
protected
ObjectWriter
(ObjectMapper mapper, SerializationConfig config, JavaType rootType, tools.jackson.core.PrettyPrinter pp) Constructor used byObjectMapper
for initial instantiationprotected
ObjectWriter
(ObjectWriter base, SerializationConfig config) Copy constructor used for building variations.protected
ObjectWriter
(ObjectWriter base, SerializationConfig config, GeneratorSettings genSettings, ObjectWriter.Prefetch prefetch) Copy constructor used for building variations. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
_assertNotNull
(String paramName, Object src) protected final void
_configAndWriteValue
(SerializationContextExt ctxt, tools.jackson.core.JsonGenerator gen, Object value) Method called to configure the generator as necessary and then call write functionalityprotected ObjectWriter
_new
(GeneratorSettings genSettings, ObjectWriter.Prefetch prefetch) Overridable factory method called by various "withXxx()" methods.protected ObjectWriter
_new
(ObjectWriter base, SerializationConfig config) Overridable factory method called by various "withXxx()" methodsprotected final SequenceWriter
_newSequenceWriter
(SerializationContextExt ctxt, boolean wrapInArray, tools.jackson.core.JsonGenerator gen, boolean managedInput) Overridable factory method called bywriteValues(OutputStream)
method (and its various overrides), and initializes it as necessary.protected final SerializationContextExt
Overridable helper method used for constructingSerializationContext
to use for serialization.protected void
_verifySchemaType
(tools.jackson.core.FormatSchema schema) void
acceptJsonFormatVisitor
(Class<?> type, JsonFormatVisitorWrapper visitor) void
acceptJsonFormatVisitor
(JavaType type, JsonFormatVisitorWrapper visitor) Method for visiting type hierarchy for given type, using specified visitor.tools.jackson.core.JsonGenerator
createGenerator
(DataOutput target) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,DataOutput)
.tools.jackson.core.JsonGenerator
createGenerator
(File target, tools.jackson.core.JsonEncoding enc) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,File,JsonEncoding)
.tools.jackson.core.JsonGenerator
createGenerator
(OutputStream target) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,OutputStream)
.tools.jackson.core.JsonGenerator
createGenerator
(OutputStream target, tools.jackson.core.JsonEncoding enc) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,OutputStream,JsonEncoding)
.tools.jackson.core.JsonGenerator
createGenerator
(Writer target) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,Writer)
.tools.jackson.core.JsonGenerator
createGenerator
(Path target, tools.jackson.core.JsonEncoding enc) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,Path,JsonEncoding)
.Method that will construct a new instance that uses specific type as the root type for serialization, instead of runtime dynamic type of the root object itself.forType
(tools.jackson.core.type.TypeReference<?> rootType) Method that will construct a new instance that uses specific type as the root type for serialization, instead of runtime dynamic type of the root object itself.Method that will construct a new instance that uses specific type as the root type for serialization, instead of runtime dynamic type of the root object itself.tools.jackson.core.TokenStreamFactory
Deprecated.boolean
Diagnostics method that can be called to check whether this writer has pre-fetched serializer to use: pre-fetching improves performance when writer instances are reused as it avoids a per-call serializer lookup.boolean
isEnabled
(tools.jackson.core.StreamWriteFeature f) boolean
boolean
boolean
<T extends JsonNode>
TvalueToTree
(Object fromValue) Method that will convert given Java value (usually bean) into its equivalent Tree modelJsonNode
representation.tools.jackson.core.Version
version()
Method that will return version information stored in and read from jar that contains this class.with
(DateFormat df) Fluent factory method that will construct a new writer instance that will use specified date format for serializing dates; or if null passed, one that will serialize dates as numeric timestamps.with
(tools.jackson.core.Base64Variant b64variant) Method that will construct a new instance that uses specified defaultBase64Variant
for base64 encodingwith
(tools.jackson.core.FormatFeature feature) with
(tools.jackson.core.FormatSchema schema) Method that will construct a new instance that uses specific format schema for serialization.with
(tools.jackson.core.io.CharacterEscapes escapes) with
(tools.jackson.core.PrettyPrinter pp) Method that will construct a new instance that will use specified pretty printer (or, if null, will not do any pretty-printing)with
(tools.jackson.core.StreamWriteFeature feature) with
(ContextAttributes attrs) Mutant factory for overriding set of (default) attributes forObjectWriter
to use.with
(DatatypeFeature feature) Method for constructing a new instance that is configured with specified feature enabled.with
(FilterProvider filterProvider) Method that will construct a new instance that uses specified provider for resolving filter instances by id.with
(SerializationFeature feature) Method for constructing a new instance that is configured with specified feature enabled.with
(SerializationFeature first, SerializationFeature... other) Method for constructing a new instance that is configured with specified features enabled.withAttribute
(Object key, Object value) withAttributes
(Map<?, ?> attrs) Mutant factory method that allows construction of a new writer instance that uses specified set of default attribute values.Method that will construct a new instance that will use the default pretty printer for serialization.withFeatures
(tools.jackson.core.FormatFeature... features) withFeatures
(tools.jackson.core.StreamWriteFeature... features) withFeatures
(DatatypeFeature... features) Method for constructing a new instance that is configured with specified features enabled.withFeatures
(SerializationFeature... features) Method for constructing a new instance that is configured with specified features enabled.without
(tools.jackson.core.FormatFeature feature) without
(tools.jackson.core.StreamWriteFeature feature) without
(DatatypeFeature feature) Method for constructing a new instance that is configured with specified feature disabled.without
(SerializationFeature feature) Method for constructing a new instance that is configured with specified feature disabled.without
(SerializationFeature first, SerializationFeature... other) Method for constructing a new instance that is configured with specified features disabled.withoutAttribute
(Object key) withoutFeatures
(tools.jackson.core.FormatFeature... features) withoutFeatures
(tools.jackson.core.StreamWriteFeature... features) withoutFeatures
(DatatypeFeature... features) Method for constructing a new instance that is configured with specified features disabled.withoutFeatures
(SerializationFeature... features) Method for constructing a new instance that is configured with specified features disabled.Convenience method that is same as calling:withRootName("")
which will forcibly prevent use of root name wrapping when writing values with thisObjectWriter
.withRootName
(String rootName) Method for constructing a new instance with configuration that specifies what root name to use for "root element wrapping".withRootName
(PropertyName rootName) withRootValueSeparator
(tools.jackson.core.SerializableString sep) Method that will construct a new instance that uses specified serialization view for serialization (with null basically disables view processing)void
writeValue
(DataOutput target, Object value) void
writeValue
(File target, Object value) Method that can be used to serialize any Java value as JSON output, written to File provided.void
writeValue
(OutputStream target, Object value) Method that can be used to serialize any Java value as JSON output, using output stream provided (using encodingJsonEncoding.UTF8
).void
writeValue
(Writer target, Object value) Method that can be used to serialize any Java value as JSON output, using Writer provided.void
writeValue
(Path target, Object value) Method that can be used to serialize any Java value as JSON output, written to Path provided.void
writeValue
(tools.jackson.core.JsonGenerator g, Object value) Method that can be used to serialize any Java value as JSON output, using providedJsonGenerator
.byte[]
writeValueAsBytes
(Object value) Method that can be used to serialize any Java value as a byte array.writeValueAsString
(Object value) Method that can be used to serialize any Java value as a String.writeValues
(DataOutput target) writeValues
(File target) Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
.writeValues
(OutputStream target) Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
.writeValues
(Writer target) Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
.writeValues
(Path target) Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
.writeValues
(tools.jackson.core.JsonGenerator g) Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
.writeValuesAsArray
(DataOutput target) writeValuesAsArray
(File target) Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
.writeValuesAsArray
(OutputStream target) Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
.writeValuesAsArray
(Writer target) Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
.writeValuesAsArray
(Path target) Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
.writeValuesAsArray
(tools.jackson.core.JsonGenerator g) Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
.
-
Field Details
-
_config
General serialization configuration settings -
_serializationContexts
Factory used for constructing per-callSerializationContext
s.Note: while serializers are only exposed
SerializationContext
, mappers and readers need to access additional API defined bySerializationContextExt
-
_generatorFactory
protected final tools.jackson.core.TokenStreamFactory _generatorFactoryFactory used for constructingJsonGenerator
s -
_generatorSettings
Container for settings that need to be passed toJsonGenerator
constructed for serializing values. -
_prefetch
We may pre-fetch serializer if root type is known (has been explicitly declared), and if so, reuse it afterwards. This allows avoiding further serializer lookups and increases performance a bit on cases where readers are reused.
-
-
Constructor Details
-
ObjectWriter
protected ObjectWriter(ObjectMapper mapper, SerializationConfig config, JavaType rootType, tools.jackson.core.PrettyPrinter pp) Constructor used byObjectMapper
for initial instantiation -
ObjectWriter
Alternative constructor for initial instantiation byObjectMapper
-
ObjectWriter
protected ObjectWriter(ObjectMapper mapper, SerializationConfig config, tools.jackson.core.FormatSchema s) Alternative constructor for initial instantiation byObjectMapper
-
ObjectWriter
protected ObjectWriter(ObjectWriter base, SerializationConfig config, GeneratorSettings genSettings, ObjectWriter.Prefetch prefetch) Copy constructor used for building variations. -
ObjectWriter
Copy constructor used for building variations.
-
-
Method Details
-
version
public tools.jackson.core.Version version()Method that will return version information stored in and read from jar that contains this class.- Specified by:
version
in interfacetools.jackson.core.Versioned
-
_new
Overridable factory method called by various "withXxx()" methods -
_new
Overridable factory method called by various "withXxx()" methods. It assumes `this` as base for settings other than those directly passed in. -
_newSequenceWriter
protected final SequenceWriter _newSequenceWriter(SerializationContextExt ctxt, boolean wrapInArray, tools.jackson.core.JsonGenerator gen, boolean managedInput) throws tools.jackson.core.JacksonException Overridable factory method called bywriteValues(OutputStream)
method (and its various overrides), and initializes it as necessary.- Throws:
tools.jackson.core.JacksonException
-
with
Method for constructing a new instance that is configured with specified feature enabled. -
with
Method for constructing a new instance that is configured with specified features enabled. -
withFeatures
Method for constructing a new instance that is configured with specified features enabled. -
without
Method for constructing a new instance that is configured with specified feature disabled. -
without
Method for constructing a new instance that is configured with specified features disabled. -
withoutFeatures
Method for constructing a new instance that is configured with specified features disabled. -
with
Method for constructing a new instance that is configured with specified feature enabled. -
withFeatures
Method for constructing a new instance that is configured with specified features enabled. -
without
Method for constructing a new instance that is configured with specified feature disabled. -
withoutFeatures
Method for constructing a new instance that is configured with specified features disabled. -
with
-
withFeatures
-
without
-
withoutFeatures
-
with
-
withFeatures
-
without
-
withoutFeatures
-
forType
Method that will construct a new instance that uses specific type as the root type for serialization, instead of runtime dynamic type of the root object itself.Note that method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
forType
Method that will construct a new instance that uses specific type as the root type for serialization, instead of runtime dynamic type of the root object itself. -
forType
Method that will construct a new instance that uses specific type as the root type for serialization, instead of runtime dynamic type of the root object itself. -
with
Fluent factory method that will construct a new writer instance that will use specified date format for serializing dates; or if null passed, one that will serialize dates as numeric timestamps.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
withDefaultPrettyPrinter
Method that will construct a new instance that will use the default pretty printer for serialization. -
with
Method that will construct a new instance that uses specified provider for resolving filter instances by id. -
with
Method that will construct a new instance that will use specified pretty printer (or, if null, will not do any pretty-printing) -
withRootName
Method for constructing a new instance with configuration that specifies what root name to use for "root element wrapping". SeeMapperConfigBase.withRootName(String)
for details.Note that method does NOT change state of this reader, but rather construct and returns a newly configured instance.
- Parameters:
rootName
- Root name to use, if non-empty; `null` for "use defaults", and empty String ("") for "do NOT add root wrapper"
-
withRootName
-
withoutRootName
Convenience method that is same as calling:withRootName("")
which will forcibly prevent use of root name wrapping when writing values with thisObjectWriter
. -
with
Method that will construct a new instance that uses specific format schema for serialization.Note that method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
withView
Method that will construct a new instance that uses specified serialization view for serialization (with null basically disables view processing)Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
with
-
with
-
with
Method that will construct a new instance that uses specified defaultBase64Variant
for base64 encoding -
with
-
with
Mutant factory for overriding set of (default) attributes forObjectWriter
to use.Note that this will replace defaults passed by
ObjectMapper
.- Parameters:
attrs
- DefaultContextAttributes
to use with a writer- Returns:
ObjectWriter
instance with specified default attributes (which is usually a newly constructed writer instance with otherwise identical settings)
-
withAttributes
Mutant factory method that allows construction of a new writer instance that uses specified set of default attribute values. -
withAttribute
-
withoutAttribute
-
withRootValueSeparator
-
withRootValueSeparator
-
createGenerator
Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,OutputStream)
.- Since:
- 3.0
-
createGenerator
public tools.jackson.core.JsonGenerator createGenerator(OutputStream target, tools.jackson.core.JsonEncoding enc) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,OutputStream,JsonEncoding)
.- Since:
- 3.0
-
createGenerator
Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,Writer)
.- Since:
- 3.0
-
createGenerator
public tools.jackson.core.JsonGenerator createGenerator(File target, tools.jackson.core.JsonEncoding enc) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,File,JsonEncoding)
.- Since:
- 3.0
-
createGenerator
public tools.jackson.core.JsonGenerator createGenerator(Path target, tools.jackson.core.JsonEncoding enc) Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,Path,JsonEncoding)
.- Since:
- 3.0
-
createGenerator
Factory method for constructingJsonGenerator
that is properly wired to allow callbacks for serialization: basically constructs aObjectWriteContext
and then callsTokenStreamFactory.createGenerator(ObjectWriteContext,DataOutput)
.- Since:
- 3.0
-
createObjectNode
-
createArrayNode
-
writeValues
Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
. Sequence is not surrounded by JSON array; some backend types may not support writing of such sequences as root level. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.- Parameters:
target
- Target file to write value sequence to.- Throws:
tools.jackson.core.JacksonException
-
writeValues
Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
. Sequence is not surrounded by JSON array; some backend types may not support writing of such sequences as root level. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.- Parameters:
target
- Target path to write value sequence to.- Throws:
tools.jackson.core.JacksonException
- Since:
- 3.0
-
writeValues
public SequenceWriter writeValues(tools.jackson.core.JsonGenerator g) throws tools.jackson.core.JacksonException Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
. Sequence is not surrounded by JSON array; some backend types may not support writing of such sequences as root level. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure that all content gets flushed by the generator. However, since aJsonGenerator
is explicitly passed, it will NOT be closed whenSequenceWriter.close()
is called.- Parameters:
g
- Low-level generator caller has already constructed that will be used for actual writing of token stream.- Throws:
tools.jackson.core.JacksonException
-
writeValues
Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
. Sequence is not surrounded by JSON array; some backend types may not support writing of such sequences as root level. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.- Parameters:
target
- Target writer to use for writing the token stream- Throws:
tools.jackson.core.JacksonException
-
writeValues
Method for creating aSequenceWriter
to write a sequence of root values using configuration of thisObjectWriter
. Sequence is not surrounded by JSON array; some backend types may not support writing of such sequences as root level. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.- Parameters:
target
- Physical output stream to use for writing the token stream- Throws:
tools.jackson.core.JacksonException
-
writeValues
- Throws:
tools.jackson.core.JacksonException
-
writeValuesAsArray
Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.Note that the type to use with
forType(Class)
needs to be type of individual values (elements) to write and NOT matching array orCollection
type.- Parameters:
target
- File to write token stream to- Throws:
tools.jackson.core.JacksonException
-
writeValuesAsArray
Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.Note that the type to use with
forType(Class)
needs to be type of individual values (elements) to write and NOT matching array orCollection
type.- Parameters:
target
- Path to write token stream to- Throws:
tools.jackson.core.JacksonException
- Since:
- 3.0
-
writeValuesAsArray
public SequenceWriter writeValuesAsArray(tools.jackson.core.JsonGenerator g) throws tools.jackson.core.JacksonException Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure that all content gets flushed by the generator. However, since aJsonGenerator
is explicitly passed, it will NOT be closed whenSequenceWriter.close()
is called.Note that the type to use with
forType(Class)
needs to be type of individual values (elements) to write and NOT matching array orCollection
type.- Parameters:
g
- Underlying generator to use for writing the token stream- Throws:
tools.jackson.core.JacksonException
-
writeValuesAsArray
Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.Note that the type to use with
forType(Class)
needs to be type of individual values (elements) to write and NOT matching array orCollection
type.- Parameters:
target
- Writer to use for writing the token stream- Throws:
tools.jackson.core.JacksonException
-
writeValuesAsArray
public SequenceWriter writeValuesAsArray(OutputStream target) throws tools.jackson.core.JacksonException Method for creating aSequenceWriter
to write an array of root-level values, using configuration of thisObjectWriter
. Resulting writer needs to beSequenceWriter.close()
d after all values have been written to ensure closing of underlying generator and output stream.Note that the type to use with
forType(Class)
needs to be type of individual values (elements) to write and NOT matching array orCollection
type.- Parameters:
target
- Physical output stream to use for writing the token stream- Throws:
tools.jackson.core.JacksonException
-
writeValuesAsArray
public SequenceWriter writeValuesAsArray(DataOutput target) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
isEnabled
-
isEnabled
-
isEnabled
-
isEnabled
public boolean isEnabled(tools.jackson.core.StreamWriteFeature f) -
getConfig
-
generatorFactory
public tools.jackson.core.TokenStreamFactory generatorFactory()- Since:
- 3.0
-
typeFactory
-
hasPrefetchedSerializer
public boolean hasPrefetchedSerializer()Diagnostics method that can be called to check whether this writer has pre-fetched serializer to use: pre-fetching improves performance when writer instances are reused as it avoids a per-call serializer lookup. -
getAttributes
-
getTypeFactory
Deprecated.Since 3.0 usetypeFactory()
-
writeValue
public void writeValue(tools.jackson.core.JsonGenerator g, Object value) throws tools.jackson.core.JacksonException Method that can be used to serialize any Java value as JSON output, using providedJsonGenerator
.- Throws:
tools.jackson.core.JacksonException
-
writeValue
Method that can be used to serialize any Java value as JSON output, written to File provided.- Throws:
tools.jackson.core.JacksonException
-
writeValue
Method that can be used to serialize any Java value as JSON output, written to Path provided.- Throws:
tools.jackson.core.JacksonException
- Since:
- 3.0
-
writeValue
public void writeValue(OutputStream target, Object value) throws tools.jackson.core.JacksonException Method that can be used to serialize any Java value as JSON output, using output stream provided (using encodingJsonEncoding.UTF8
).Note: method does not close the underlying stream explicitly here; however,
TokenStreamFactory
this mapper uses may choose to close the stream depending on its settings (by default, it will try to close it whenJsonGenerator
we construct is closed).- Throws:
tools.jackson.core.JacksonException
-
writeValue
Method that can be used to serialize any Java value as JSON output, using Writer provided.Note: method does not close the underlying stream explicitly here; however,
TokenStreamFactory
this mapper uses may choose to close the stream depending on its settings (by default, it will try to close it whenJsonGenerator
we construct is closed).- Throws:
tools.jackson.core.JacksonException
-
writeValue
- Throws:
tools.jackson.core.JacksonException
-
writeValueAsString
Method that can be used to serialize any Java value as a String. Functionally equivalent to callingwriteValue(Writer,Object)
withStringWriter
and constructing String, but more efficient.- Throws:
tools.jackson.core.JacksonException
-
writeValueAsBytes
Method that can be used to serialize any Java value as a byte array. Functionally equivalent to callingwriteValue(Writer,Object)
withByteArrayOutputStream
and getting bytes, but more efficient. Encoding used will be UTF-8.- Throws:
tools.jackson.core.JacksonException
-
_configAndWriteValue
protected final void _configAndWriteValue(SerializationContextExt ctxt, tools.jackson.core.JsonGenerator gen, Object value) throws tools.jackson.core.JacksonException Method called to configure the generator as necessary and then call write functionality- Throws:
tools.jackson.core.JacksonException
-
valueToTree
public <T extends JsonNode> T valueToTree(Object fromValue) throws tools.jackson.core.JacksonException Method that will convert given Java value (usually bean) into its equivalent Tree modelJsonNode
representation. Functionally similar to serializing value into token stream and parsing that stream back as tree model node, but more efficient asTokenBuffer
is used to contain the intermediate representation instead of fully serialized contents.NOTE: while results are usually identical to that of serialization followed by deserialization, this is not always the case. In some cases serialization into intermediate representation will retain encapsulation of things like raw value (
RawValue
) or basic node identity (JsonNode
). If so, result is a valid tree, but values are not re-constructed through actual format representation. So if transformation requires actual materialization of encoded content, it will be necessary to do actual serialization.- Type Parameters:
T
- Actual node type; usually either basicJsonNode
orObjectNode
- Parameters:
fromValue
- Java value to convert- Returns:
- (non-null) Root node of the resulting content tree: in case of
null
value node for whichJsonNode.isNull()
returnstrue
. - Throws:
tools.jackson.core.JacksonException
- Since:
- 3.0
-
acceptJsonFormatVisitor
Method for visiting type hierarchy for given type, using specified visitor. Visitation usesSerializer
hierarchy and related propertiesThis method can be used for things like generating Json Schema instance for specified type.
- Parameters:
type
- Type to generate schema for (possibly with generic signature)
-
acceptJsonFormatVisitor
-
_serializationContext
Overridable helper method used for constructingSerializationContext
to use for serialization. -
_verifySchemaType
protected void _verifySchemaType(tools.jackson.core.FormatSchema schema) -
_assertNotNull
-
typeFactory()