public class ObjectMapper extends ObjectCodec implements Versioned, Serializable
JsonNode
), as well as
related functionality for performing conversions.
It is also highly customizable to work both with different styles of JSON
content, and to support more advanced Object concepts such as
polymorphism and Object identity.
ObjectMapper
also acts as a factory for more advanced ObjectReader
and ObjectWriter
classes.
Mapper (and ObjectReader
s, ObjectWriter
s it constructs) will
use instances of JsonParser
and JsonGenerator
for implementing actual reading/writing of JSON.
Note that although most read and write methods are exposed through this class,
some of the functionality is only exposed via ObjectReader
and
ObjectWriter
: specifically, reading/writing of longer sequences of
values is only available through ObjectReader.readValues(InputStream)
and ObjectWriter.writeValues(OutputStream)
.
Simplest usage is of form:
final ObjectMapper mapper = new ObjectMapper(); // can use static singleton, inject: just make sure to reuse!
MyValue value = new MyValue();
// ... and configure
File newState = new File("my-stuff.json");
mapper.writeValue(newState, value); // writes JSON serialization of MyValue instance
// or, read
MyValue older = mapper.readValue(new File("my-older-stuff.json"), MyValue.class);
// Or if you prefer JSON Tree representation:
JsonNode root = mapper.readTree(newState);
// and find values by, for example, using a JsonPointer
expression:
int age = root.at("/personal/age").getValueAsInt();
The main conversion API is defined in ObjectCodec
, so that
implementation details of this class need not be exposed to
streaming parser and generator classes. Usage via ObjectCodec
is,
however, usually only for cases where dependency to ObjectMapper
is
either not possible (from Streaming API), or undesireable (when only relying
on Streaming API).
Mapper instances are fully thread-safe provided that ALL configuration of the instance occurs before ANY read or write calls. If configuration of a mapper instance is modified after first usage, changes may or may not take effect, and configuration calls themselves may fail. If you need to use different configuration, you have two main possibilities:
ObjectReader
for reading, ObjectWriter
for writing.
Both types are fully immutable and you can freely create new instances with different
configuration using either factory methods of ObjectMapper
, or readers/writers
themselves. Construction of new ObjectReader
s and ObjectWriter
s is
a very light-weight operation so it is usually appropriate to create these on per-call
basis, as needed, for configuring things like optional indentation of JSON.
ObjectReader
and
ObjectWriter
, you may need to use multiple ObjectMapper
instead (for example:
you cannot change mix-in annotations on-the-fly; or, set of custom (de)serializers).
To help with this usage, you may want to use method copy()
which creates a clone
of the mapper with specific configuration, and allows configuration of the copied instance
before it gets used. Note that copy()
operation is as expensive as constructing
a new ObjectMapper
instance: if possible, you should still pool and reuse mappers
if you intend to use them for multiple operations.
Note on caching: root-level deserializers are always cached, and accessed using full (generics-aware) type information. This is different from caching of referenced types, which is more limited and is done only for a subset of all deserializer types. The main reason for difference is that at root-level there is no incoming reference (and hence no referencing property, no referral information or annotations to produce differing deserializers), and that the performance impact greatest at root level (since it'll essentially cache the full graph of deserializers involved).
Notes on security: use "default typing" feature (see enableDefaultTyping()
)
is a potential security risk, if used with untrusted content (content generated by
untrusted external parties). If so, you may want to construct a custom
TypeResolverBuilder
implementation to limit possible types to instantiate,
(using setDefaultTyping(com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder<?>)
).
Modifier and Type | Class and Description |
---|---|
static class |
ObjectMapper.DefaultTypeResolverBuilder
Customized
TypeResolverBuilder that provides type resolver builders
used with so-called "default typing"
(see activateDefaultTyping(PolymorphicTypeValidator) for details). |
static class |
ObjectMapper.DefaultTyping
Enumeration used with
activateDefaultTyping(PolymorphicTypeValidator)
to specify what kind of types (classes) default typing should
be used for. |
Modifier and Type | Field and Description |
---|---|
protected CoercionConfigs |
_coercionConfigs
Current set of coercion configuration definitions that define allowed
(and not allowed) coercions from secondary shapes.
|
protected ConfigOverrides |
_configOverrides
Currently active per-type configuration overrides, accessed by
declared type of property.
|
protected DeserializationConfig |
_deserializationConfig
Configuration object that defines basic global
settings for the serialization process
|
protected DefaultDeserializationContext |
_deserializationContext
Blueprint context object; stored here to allow custom
sub-classes.
|
protected InjectableValues |
_injectableValues
Provider for values to inject in deserialized POJOs.
|
protected JsonFactory |
_jsonFactory
Factory used to create
JsonParser and JsonGenerator
instances as necessary. |
protected SimpleMixInResolver |
_mixIns
Mapping that defines how to apply mix-in annotations: key is
the type to received additional annotations, and value is the
type that has annotations to "mix in".
|
protected Set<Object> |
_registeredModuleTypes
Set of module types (as per
Module.getTypeId() that have been
registered; kept track of iff MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS
is enabled, so that duplicate registration calls can be ignored
(to avoid adding same handlers multiple times, mostly). |
protected ConcurrentHashMap<JavaType,JsonDeserializer<Object>> |
_rootDeserializers
We will use a separate main-level Map for keeping track
of root-level deserializers.
|
protected SerializationConfig |
_serializationConfig
Configuration object that defines basic global
settings for the serialization process
|
protected SerializerFactory |
_serializerFactory
Serializer factory used for constructing serializers.
|
protected DefaultSerializerProvider |
_serializerProvider
Object that manages access to serializers used for serialization,
including caching.
|
protected SubtypeResolver |
_subtypeResolver
Thing used for registering sub-types, resolving them to
super/sub-types as needed.
|
protected TypeFactory |
_typeFactory
Specific factory used for creating
JavaType instances;
needed to allow modules to add more custom type handling
(mostly to support types of non-Java JVM languages) |
protected static AnnotationIntrospector |
DEFAULT_ANNOTATION_INTROSPECTOR |
protected static BaseSettings |
DEFAULT_BASE
Base settings contain defaults used for all
ObjectMapper
instances. |
Modifier | Constructor and Description |
---|---|
|
ObjectMapper()
Default constructor, which will construct the default
JsonFactory as necessary, use
SerializerProvider as its
SerializerProvider , and
BeanSerializerFactory as its
SerializerFactory . |
|
ObjectMapper(JsonFactory jf)
Constructs instance that uses specified
JsonFactory
for constructing necessary JsonParser s and/or
JsonGenerator s. |
|
ObjectMapper(JsonFactory jf,
DefaultSerializerProvider sp,
DefaultDeserializationContext dc)
Constructs instance that uses specified
JsonFactory
for constructing necessary JsonParser s and/or
JsonGenerator s, and uses given providers for accessing
serializers and deserializers. |
protected |
ObjectMapper(ObjectMapper src)
Copy-constructor, mostly used to support
copy() . |
Modifier and Type | Method and Description |
---|---|
protected void |
_assertNotNull(String paramName,
Object src) |
protected void |
_checkInvalidCopy(Class<?> exp) |
protected void |
_configAndWriteValue(JsonGenerator g,
Object value)
Deprecated.
Since 2.11.2 Use
_writeValueAndClose(com.fasterxml.jackson.core.JsonGenerator, java.lang.Object) instead |
protected TypeResolverBuilder<?> |
_constructDefaultTypeResolverBuilder(ObjectMapper.DefaultTyping applicability,
PolymorphicTypeValidator ptv)
Overridable factory method, separate to allow format-specific mappers (and specifically
XML-backed one, currently) to offer custom
TypeResolverBuilder subtypes. |
protected Object |
_convert(Object fromValue,
JavaType toValueType)
Actual conversion implementation: instead of using existing read
and write methods, much of code is inlined.
|
protected JsonDeserializer<Object> |
_findRootDeserializer(DeserializationContext ctxt,
JavaType valueType)
Method called to locate deserializer for the passed root-level value.
|
protected JsonToken |
_initForReading(JsonParser p,
JavaType targetType)
Method called to ensure that given parser is ready for reading
content for data binding.
|
protected ObjectReader |
_newReader(DeserializationConfig config)
Factory method sub-classes must override, to produce
ObjectReader
instances of proper sub-type |
protected ObjectReader |
_newReader(DeserializationConfig config,
JavaType valueType,
Object valueToUpdate,
FormatSchema schema,
InjectableValues injectableValues)
Factory method sub-classes must override, to produce
ObjectReader
instances of proper sub-type |
protected ObjectWriter |
_newWriter(SerializationConfig config)
Factory method sub-classes must override, to produce
ObjectWriter
instances of proper sub-type |
protected ObjectWriter |
_newWriter(SerializationConfig config,
FormatSchema schema)
Factory method sub-classes must override, to produce
ObjectWriter
instances of proper sub-type |
protected ObjectWriter |
_newWriter(SerializationConfig config,
JavaType rootType,
PrettyPrinter pp)
Factory method sub-classes must override, to produce
ObjectWriter
instances of proper sub-type |
protected Object |
_readMapAndClose(JsonParser p0,
JavaType valueType) |
protected JsonNode |
_readTreeAndClose(JsonParser p0)
Similar to
_readMapAndClose(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.JavaType) but specialized for JsonNode
reading. |
protected Object |
_readValue(DeserializationConfig cfg,
JsonParser p,
JavaType valueType)
Actual implementation of value reading+binding operation.
|
protected DefaultSerializerProvider |
_serializerProvider(SerializationConfig config)
Overridable helper method used for constructing
SerializerProvider to use for serialization. |
protected void |
_verifyNoTrailingTokens(JsonParser p,
DeserializationContext ctxt,
JavaType bindType) |
protected void |
_verifySchemaType(FormatSchema schema) |
protected void |
_writeValueAndClose(JsonGenerator g,
Object value)
Method called to configure the generator as necessary and then
call write functionality
|
void |
acceptJsonFormatVisitor(Class<?> type,
JsonFormatVisitorWrapper visitor)
Method for visiting type hierarchy for given type, using specified visitor.
|
void |
acceptJsonFormatVisitor(JavaType type,
JsonFormatVisitorWrapper visitor)
Method for visiting type hierarchy for given type, using specified visitor.
|
ObjectMapper |
activateDefaultTyping(PolymorphicTypeValidator ptv)
Convenience method that is equivalent to calling
|
ObjectMapper |
activateDefaultTyping(PolymorphicTypeValidator ptv,
ObjectMapper.DefaultTyping applicability)
Convenience method that is equivalent to calling
|
ObjectMapper |
activateDefaultTyping(PolymorphicTypeValidator ptv,
ObjectMapper.DefaultTyping applicability,
JsonTypeInfo.As includeAs)
Method for enabling automatic inclusion of type information ("Default Typing"),
needed for proper deserialization of polymorphic types (unless types
have been annotated with
JsonTypeInfo ). |
ObjectMapper |
activateDefaultTypingAsProperty(PolymorphicTypeValidator ptv,
ObjectMapper.DefaultTyping applicability,
String propertyName)
Method for enabling automatic inclusion of type information ("Default Typing")
-- needed for proper deserialization of polymorphic types (unless types
have been annotated with
JsonTypeInfo ) --
using "As.PROPERTY" inclusion mechanism and specified property name
to use for inclusion (default being "@class" since default type information
always uses class name as type identifier) |
ObjectMapper |
addHandler(DeserializationProblemHandler h)
Method for adding specified
DeserializationProblemHandler
to be used for handling specific problems during deserialization. |
ObjectMapper |
addMixIn(Class<?> target,
Class<?> mixinSource)
Method to use for adding mix-in annotations to use for augmenting
specified class or interface.
|
void |
addMixInAnnotations(Class<?> target,
Class<?> mixinSource)
Deprecated.
Since 2.5: replaced by a fluent form of the method;
addMixIn(Class, Class) . |
boolean |
canDeserialize(JavaType type)
Method that can be called to check whether mapper thinks
it could deserialize an Object of given type.
|
boolean |
canDeserialize(JavaType type,
AtomicReference<Throwable> cause)
Method similar to
canDeserialize(JavaType) but that can return
actual Throwable that was thrown when trying to construct
serializer: this may be useful in figuring out what the actual problem is. |
boolean |
canSerialize(Class<?> type)
Method that can be called to check whether mapper thinks
it could serialize an instance of given Class.
|
boolean |
canSerialize(Class<?> type,
AtomicReference<Throwable> cause)
Method similar to
canSerialize(Class) but that can return
actual Throwable that was thrown when trying to construct
serializer: this may be useful in figuring out what the actual problem is. |
ObjectMapper |
clearProblemHandlers()
Method for removing all registered
DeserializationProblemHandler s
instances from this mapper. |
MutableCoercionConfig |
coercionConfigDefaults()
Accessor for
MutableCoercionConfig through which
default (fallback) coercion configurations can be changed. |
MutableCoercionConfig |
coercionConfigFor(Class<?> physicalType)
Accessor for
MutableCoercionConfig through which
coercion configuration for specified physical target type can be set. |
MutableCoercionConfig |
coercionConfigFor(LogicalType logicalType)
Accessor for
MutableCoercionConfig through which
coercion configuration for specified logical target type can be set. |
MutableConfigOverride |
configOverride(Class<?> type)
Accessor for getting a mutable configuration override object for
given type, needed to add or change per-type overrides applied
to properties of given type.
|
ObjectMapper |
configure(DeserializationFeature f,
boolean state)
Method for changing state of an on/off deserialization feature for
this object mapper.
|
ObjectMapper |
configure(JsonGenerator.Feature f,
boolean state)
Method for changing state of an on/off
JsonGenerator feature for
generator instances this object mapper creates. |
ObjectMapper |
configure(JsonParser.Feature f,
boolean state)
Method for changing state of specified
JsonParser.Feature s
for parser instances this object mapper creates. |
ObjectMapper |
configure(MapperFeature f,
boolean state)
Deprecated.
Since 2.13 use
JsonMapper.builder().configure(...) |
ObjectMapper |
configure(SerializationFeature f,
boolean state)
Method for changing state of an on/off serialization feature for
this object mapper.
|
JavaType |
constructType(Type t)
Convenience method for constructing
JavaType out of given
type (typically java.lang.Class ), but without explicit
context. |
JavaType |
constructType(TypeReference<?> typeRef)
Convenience method for constructing
JavaType out of given
type reference. |
<T> T |
convertValue(Object fromValue,
Class<T> toValueType)
Convenience method for doing two-step conversion from given value, into
instance of given value type, by writing value into temporary buffer
and reading from the buffer into specified target type.
|
<T> T |
convertValue(Object fromValue,
JavaType toValueType)
|
<T> T |
convertValue(Object fromValue,
TypeReference<T> toValueTypeRef)
|
ObjectMapper |
copy()
Method for creating a new
ObjectMapper instance that
has same initial configuration as this instance. |
ArrayNode |
createArrayNode()
Note: return type is co-variant, as basic ObjectCodec
abstraction cannot refer to concrete node types (as it's
part of core package, whereas impls are part of mapper
package)
|
protected DefaultDeserializationContext |
createDeserializationContext(JsonParser p,
DeserializationConfig cfg)
Internal helper method called to create an instance of
DeserializationContext
for deserializing a single root value. |
JsonGenerator |
createGenerator(DataOutput out)
Factory method for constructing properly initialized
JsonGenerator
to write content using specified DataOutput . |
JsonGenerator |
createGenerator(File outputFile,
JsonEncoding enc)
Factory method for constructing properly initialized
JsonGenerator
to write content to specified File , using specified encoding. |
JsonGenerator |
createGenerator(OutputStream out)
Factory method for constructing properly initialized
JsonGenerator
to write content using specified OutputStream . |
JsonGenerator |
createGenerator(OutputStream out,
JsonEncoding enc)
Factory method for constructing properly initialized
JsonGenerator
to write content using specified OutputStream and encoding. |
JsonGenerator |
createGenerator(Writer w)
Factory method for constructing properly initialized
JsonGenerator
to write content using specified Writer . |
JsonParser |
createNonBlockingByteArrayParser()
Factory method for constructing properly initialized
JsonParser
to read content using non-blocking (asynchronous) mode. |
ObjectNode |
createObjectNode()
Note: return type is co-variant, as basic ObjectCodec
abstraction cannot refer to concrete node types (as it's
part of core package, whereas impls are part of mapper
package)
|
JsonParser |
createParser(byte[] content)
Factory method for constructing properly initialized
JsonParser
to read content from specified byte array. |
JsonParser |
createParser(byte[] content,
int offset,
int len)
Factory method for constructing properly initialized
JsonParser
to read content from specified byte array. |
JsonParser |
createParser(char[] content)
Factory method for constructing properly initialized
JsonParser
to read content from specified character array
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete. |
JsonParser |
createParser(char[] content,
int offset,
int len)
Factory method for constructing properly initialized
JsonParser
to read content from specified character array. |
JsonParser |
createParser(DataInput content)
Factory method for constructing properly initialized
JsonParser
to read content using specified DataInput . |
JsonParser |
createParser(File src)
Factory method for constructing properly initialized
JsonParser
to read content from specified File . |
JsonParser |
createParser(InputStream in)
Factory method for constructing properly initialized
JsonParser
to read content using specified InputStream . |
JsonParser |
createParser(Reader r)
Factory method for constructing properly initialized
JsonParser
to read content using specified Reader . |
JsonParser |
createParser(String content)
Factory method for constructing properly initialized
JsonParser
to read content from specified String. |
JsonParser |
createParser(URL src)
Factory method for constructing properly initialized
JsonParser
to read content from specified File . |
ObjectMapper |
deactivateDefaultTyping()
Method for disabling automatic inclusion of type information; if so, only
explicitly annotated types (ones with
JsonTypeInfo ) will have
additional embedded type information. |
protected ClassIntrospector |
defaultClassIntrospector()
Overridable helper method used to construct default
ClassIntrospector
to use. |
ObjectMapper |
disable(DeserializationFeature feature)
Method for enabling specified
DeserializationConfig features. |
ObjectMapper |
disable(DeserializationFeature first,
DeserializationFeature... f)
Method for enabling specified
DeserializationConfig features. |
ObjectMapper |
disable(JsonGenerator.Feature... features)
Method for disabling specified
JsonGenerator.Feature s
for parser instances this object mapper creates. |
ObjectMapper |
disable(JsonParser.Feature... features)
Method for disabling specified
JsonParser.Feature s
for parser instances this object mapper creates. |
ObjectMapper |
disable(MapperFeature... f)
Deprecated.
Since 2.13 use
JsonMapper.builder().disable(...) |
ObjectMapper |
disable(SerializationFeature f)
Method for enabling specified
DeserializationConfig features. |
ObjectMapper |
disable(SerializationFeature first,
SerializationFeature... f)
Method for enabling specified
DeserializationConfig features. |
ObjectMapper |
disableDefaultTyping()
Deprecated.
Since 2.10 use
deactivateDefaultTyping() instead |
ObjectMapper |
enable(DeserializationFeature feature)
Method for enabling specified
DeserializationConfig features. |
ObjectMapper |
enable(DeserializationFeature first,
DeserializationFeature... f)
Method for enabling specified
DeserializationConfig features. |
ObjectMapper |
enable(JsonGenerator.Feature... features)
Method for enabling specified
JsonGenerator.Feature s
for parser instances this object mapper creates. |
ObjectMapper |
enable(JsonParser.Feature... features)
Method for enabling specified
JsonParser.Feature s
for parser instances this object mapper creates. |
ObjectMapper |
enable(MapperFeature... f)
Deprecated.
Since 2.13 use
JsonMapper.builder().enable(...) |
ObjectMapper |
enable(SerializationFeature f)
Method for enabling specified
DeserializationConfig feature. |
ObjectMapper |
enable(SerializationFeature first,
SerializationFeature... f)
Method for enabling specified
DeserializationConfig features. |
ObjectMapper |
enableDefaultTyping()
Deprecated.
Since 2.10 use
activateDefaultTyping(PolymorphicTypeValidator) instead |
ObjectMapper |
enableDefaultTyping(ObjectMapper.DefaultTyping dti)
Deprecated.
Since 2.10 use
activateDefaultTyping(PolymorphicTypeValidator,DefaultTyping) instead |
ObjectMapper |
enableDefaultTyping(ObjectMapper.DefaultTyping applicability,
JsonTypeInfo.As includeAs)
Deprecated.
Since 2.10 use
activateDefaultTyping(PolymorphicTypeValidator,DefaultTyping,JsonTypeInfo.As) instead |
ObjectMapper |
enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping applicability,
String propertyName)
Deprecated.
Since 2.10 use
activateDefaultTypingAsProperty(PolymorphicTypeValidator,DefaultTyping,String) instead |
ObjectMapper |
findAndRegisterModules()
Convenience method that is functionally equivalent to:
mapper.registerModules(mapper.findModules());
|
Class<?> |
findMixInClassFor(Class<?> cls) |
static List<Module> |
findModules()
Method for locating available methods, using JDK
ServiceLoader
facility, along with module-provided SPI. |
static List<Module> |
findModules(ClassLoader classLoader)
Method for locating available methods, using JDK
ServiceLoader
facility, along with module-provided SPI. |
JsonSchema |
generateJsonSchema(Class<?> t)
Deprecated.
Since 2.6 use external JSON Schema generator (https://github.com/FasterXML/jackson-module-jsonSchema)
(which under the hood calls
acceptJsonFormatVisitor(JavaType, JsonFormatVisitorWrapper) ) |
DateFormat |
getDateFormat() |
DeserializationConfig |
getDeserializationConfig()
Method that returns
the shared default
DeserializationConfig object
that defines configuration settings for deserialization. |
DeserializationContext |
getDeserializationContext()
Method for getting current
DeserializationContext . |
JsonFactory |
getFactory() |
InjectableValues |
getInjectableValues() |
JsonNodeFactory |
getNodeFactory()
Method that can be used to get hold of
JsonNodeFactory
that this mapper will use when directly constructing
root JsonNode instances for Trees. |
PolymorphicTypeValidator |
getPolymorphicTypeValidator()
Accessor for configured
PolymorphicTypeValidator used for validating
polymorphic subtypes used with explicit polymorphic types (annotation-based),
but NOT one with "default typing" (see activateDefaultTyping(PolymorphicTypeValidator)
for details). |
PropertyNamingStrategy |
getPropertyNamingStrategy() |
Set<Object> |
getRegisteredModuleIds()
The set of
Module typeIds that are registered in this
ObjectMapper, if (and only if!)
MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS
is enabled AND module being added returns non-null value
for its Module.getTypeId() . |
SerializationConfig |
getSerializationConfig()
Method that returns the shared default
SerializationConfig
object that defines configuration settings for serialization. |
SerializerFactory |
getSerializerFactory()
Method for getting current
SerializerFactory . |
SerializerProvider |
getSerializerProvider()
Accessor for the "blueprint" (or, factory) instance, from which instances
are created by calling
DefaultSerializerProvider.createInstance(com.fasterxml.jackson.databind.SerializationConfig, com.fasterxml.jackson.databind.ser.SerializerFactory) . |
SerializerProvider |
getSerializerProviderInstance()
Accessor for constructing and returning a
SerializerProvider
instance that may be used for accessing serializers. |
SubtypeResolver |
getSubtypeResolver()
Method for accessing subtype resolver in use.
|
TypeFactory |
getTypeFactory()
Accessor for getting currently configured
TypeFactory instance. |
VisibilityChecker<?> |
getVisibilityChecker()
Method for accessing currently configured visibility checker;
object used for determining whether given property element
(method, field, constructor) can be auto-detected or not.
|
boolean |
isEnabled(DeserializationFeature f)
Method for checking whether given deserialization-specific
feature is enabled.
|
boolean |
isEnabled(JsonFactory.Feature f)
Convenience method, equivalent to:
|
boolean |
isEnabled(JsonGenerator.Feature f) |
boolean |
isEnabled(JsonParser.Feature f) |
boolean |
isEnabled(MapperFeature f)
Method for checking whether given
MapperFeature is enabled. |
boolean |
isEnabled(SerializationFeature f)
Method for checking whether given serialization-specific
feature is enabled.
|
boolean |
isEnabled(StreamReadFeature f) |
boolean |
isEnabled(StreamWriteFeature f) |
JsonNode |
missingNode() |
int |
mixInCount() |
JsonNode |
nullNode() |
ObjectReader |
reader()
Factory method for constructing
ObjectReader with
default settings. |
ObjectReader |
reader(Base64Variant defaultBase64)
Factory method for constructing
ObjectReader that will
use specified Base64 encoding variant for Base64-encoded binary data. |
ObjectReader |
reader(Class<?> type)
Deprecated.
Since 2.5, use
readerFor(Class) instead |
ObjectReader |
reader(ContextAttributes attrs)
Factory method for constructing
ObjectReader that will
use specified default attributes. |
ObjectReader |
reader(DeserializationFeature feature)
Factory method for constructing
ObjectReader with
specified feature enabled (compared to settings that this
mapper instance has). |
ObjectReader |
reader(DeserializationFeature first,
DeserializationFeature... other)
Factory method for constructing
ObjectReader with
specified features enabled (compared to settings that this
mapper instance has). |
ObjectReader |
reader(FormatSchema schema)
Factory method for constructing
ObjectReader that will
pass specific schema object to JsonParser used for
reading content. |
ObjectReader |
reader(InjectableValues injectableValues)
Factory method for constructing
ObjectReader that will
use specified injectable values. |
ObjectReader |
reader(JavaType type)
Deprecated.
Since 2.5, use
readerFor(JavaType) instead |
ObjectReader |
reader(JsonNodeFactory f)
Factory method for constructing
ObjectReader that will
use specified JsonNodeFactory for constructing JSON trees. |
ObjectReader |
reader(TypeReference<?> type)
Deprecated.
Since 2.5, use
readerFor(TypeReference) instead |
ObjectReader |
readerFor(Class<?> type)
Factory method for constructing
ObjectReader that will
read or update instances of specified type |
ObjectReader |
readerFor(JavaType type)
Factory method for constructing
ObjectReader that will
read or update instances of specified type |
ObjectReader |
readerFor(TypeReference<?> type)
Factory method for constructing
ObjectReader that will
read or update instances of specified type |
ObjectReader |
readerForArrayOf(Class<?> type)
Factory method for constructing
ObjectReader that will
read values of a type List<type> . |
ObjectReader |
readerForListOf(Class<?> type)
Factory method for constructing
ObjectReader that will
read or update instances of a type List<type> . |
ObjectReader |
readerForMapOf(Class<?> type)
Factory method for constructing
ObjectReader that will
read or update instances of a type Map<String, type>
Functionally same as: |
ObjectReader |
readerForUpdating(Object valueToUpdate)
Factory method for constructing
ObjectReader that will
update given Object (usually Bean, but can be a Collection or Map
as well, but NOT an array) with JSON data. |
ObjectReader |
readerWithView(Class<?> view)
Factory method for constructing
ObjectReader that will
deserialize objects using specified JSON View (filter). |
JsonNode |
readTree(byte[] content)
Same as
readTree(InputStream) except content read from
passed-in byte array. |
JsonNode |
readTree(byte[] content,
int offset,
int len)
Same as
readTree(InputStream) except content read from
passed-in byte array. |
JsonNode |
readTree(File file)
Same as
readTree(InputStream) except content read from
passed-in File . |
JsonNode |
readTree(InputStream in)
Method to deserialize JSON content as tree expressed
using set of
JsonNode instances. |
<T extends TreeNode> |
readTree(JsonParser p)
Method to deserialize JSON content as a tree
JsonNode . |
JsonNode |
readTree(Reader r)
Same as
readTree(InputStream) except content accessed through
passed-in Reader |
JsonNode |
readTree(String content)
Same as
readTree(InputStream) except content read from
passed-in String |
JsonNode |
readTree(URL source)
Same as
readTree(InputStream) except content read from
passed-in URL . |
<T> T |
readValue(byte[] src,
Class<T> valueType) |
<T> T |
readValue(byte[] src,
int offset,
int len,
Class<T> valueType) |
<T> T |
readValue(byte[] src,
int offset,
int len,
JavaType valueType) |
<T> T |
readValue(byte[] src,
int offset,
int len,
TypeReference<T> valueTypeRef) |
<T> T |
readValue(byte[] src,
JavaType valueType) |
<T> T |
readValue(byte[] src,
TypeReference<T> valueTypeRef) |
<T> T |
readValue(DataInput src,
Class<T> valueType) |
<T> T |
readValue(DataInput src,
JavaType valueType) |
<T> T |
readValue(File src,
Class<T> valueType)
Method to deserialize JSON content from given file into given Java type.
|
<T> T |
readValue(File src,
JavaType valueType)
Method to deserialize JSON content from given file into given Java type.
|
<T> T |
readValue(File src,
TypeReference<T> valueTypeRef)
Method to deserialize JSON content from given file into given Java type.
|
<T> T |
readValue(InputStream src,
Class<T> valueType) |
<T> T |
readValue(InputStream src,
JavaType valueType) |
<T> T |
readValue(InputStream src,
TypeReference<T> valueTypeRef) |
<T> T |
readValue(JsonParser p,
Class<T> valueType)
Method to deserialize JSON content into a non-container
type (it can be an array type, however): typically a bean, array
or a wrapper type (like
Boolean ). |
<T> T |
readValue(JsonParser p,
JavaType valueType)
Type-safe overloaded method, basically alias for
readValue(JsonParser, Class) . |
<T> T |
readValue(JsonParser p,
ResolvedType valueType)
Method to deserialize JSON content into a Java type, reference
to which is passed as argument.
|
<T> T |
readValue(JsonParser p,
TypeReference<T> valueTypeRef)
Method to deserialize JSON content into a Java type, reference
to which is passed as argument.
|
<T> T |
readValue(Reader src,
Class<T> valueType) |
<T> T |
readValue(Reader src,
JavaType valueType) |
<T> T |
readValue(Reader src,
TypeReference<T> valueTypeRef) |
<T> T |
readValue(String content,
Class<T> valueType)
Method to deserialize JSON content from given JSON content String.
|
<T> T |
readValue(String content,
JavaType valueType)
Method to deserialize JSON content from given JSON content String.
|
<T> T |
readValue(String content,
TypeReference<T> valueTypeRef)
Method to deserialize JSON content from given JSON content String.
|
<T> T |
readValue(URL src,
Class<T> valueType)
Method to deserialize JSON content from given resource into given Java type.
|
<T> T |
readValue(URL src,
JavaType valueType)
Same as
readValue(java.net.URL, Class) except that target specified by JavaType . |
<T> T |
readValue(URL src,
TypeReference<T> valueTypeRef)
Same as
readValue(java.net.URL, Class) except that target specified by TypeReference . |
<T> MappingIterator<T> |
readValues(JsonParser p,
Class<T> valueType)
Convenience method, equivalent in function to:
|
<T> MappingIterator<T> |
readValues(JsonParser p,
JavaType valueType)
Convenience method, equivalent in function to:
|
<T> MappingIterator<T> |
readValues(JsonParser p,
ResolvedType valueType)
Convenience method, equivalent in function to:
|
<T> MappingIterator<T> |
readValues(JsonParser p,
TypeReference<T> valueTypeRef)
Method for reading sequence of Objects from parser stream.
|
ObjectMapper |
registerModule(Module module)
Method for registering a module that can extend functionality
provided by this mapper; for example, by adding providers for
custom serializers and deserializers.
|
ObjectMapper |
registerModules(Iterable<? extends Module> modules)
Convenience method for registering specified modules in order;
functionally equivalent to:
|
ObjectMapper |
registerModules(Module... modules)
Convenience method for registering specified modules in order;
functionally equivalent to:
|
void |
registerSubtypes(Class<?>... classes)
Method for registering specified class as a subtype, so that
typename-based resolution can link supertypes to subtypes
(as an alternative to using annotations).
|
void |
registerSubtypes(Collection<Class<?>> subtypes) |
void |
registerSubtypes(NamedType... types)
Method for registering specified class as a subtype, so that
typename-based resolution can link supertypes to subtypes
(as an alternative to using annotations).
|
ObjectMapper |
setAccessorNaming(AccessorNamingStrategy.Provider s)
Method for setting custom accessor naming strategy to use.
|
ObjectMapper |
setAnnotationIntrospector(AnnotationIntrospector ai)
Method for setting
AnnotationIntrospector used by this
mapper instance for both serialization and deserialization. |
ObjectMapper |
setAnnotationIntrospectors(AnnotationIntrospector serializerAI,
AnnotationIntrospector deserializerAI)
Method for changing
AnnotationIntrospector instances used
by this mapper instance for serialization and deserialization,
specifying them separately so that different introspection can be
used for different aspects |
ObjectMapper |
setBase64Variant(Base64Variant v)
Method that will configure default
Base64Variant that
byte[] serializers and deserializers will use. |
ObjectMapper |
setConfig(DeserializationConfig config)
Method that allows overriding of the underlying
DeserializationConfig
object. |
ObjectMapper |
setConfig(SerializationConfig config)
Method that allows overriding of the underlying
SerializationConfig
object, which contains serialization-specific configuration settings. |
ObjectMapper |
setConstructorDetector(ConstructorDetector cd)
Method for specifying
ConstructorDetector to use for
determining some aspects of creator auto-detection (specifically
auto-detection of constructor, and in particular behavior with
single-argument constructors). |
ObjectMapper |
setDateFormat(DateFormat dateFormat)
Method for configuring the default
DateFormat to use when serializing time
values as Strings, and deserializing from JSON Strings. |
ObjectMapper |
setDefaultAttributes(ContextAttributes attrs)
NOTE: preferred way to set the defaults is to use
Builder style
construction, see JsonMapper.builder()
(and MapperBuilder.defaultAttributes(com.fasterxml.jackson.databind.cfg.ContextAttributes) ). |
ObjectMapper |
setDefaultLeniency(Boolean b) |
ObjectMapper |
setDefaultMergeable(Boolean b)
Method for setting default Setter configuration, regarding things like
merging, null-handling; used for properties for which there are
no per-type or per-property overrides (via annotations or config overrides).
|
ObjectMapper |
setDefaultPrettyPrinter(PrettyPrinter pp)
Method for specifying
PrettyPrinter to use when "default pretty-printing"
is enabled (by enabling SerializationFeature.INDENT_OUTPUT ) |
ObjectMapper |
setDefaultPropertyInclusion(JsonInclude.Include incl)
Short-cut for:
|
ObjectMapper |
setDefaultPropertyInclusion(JsonInclude.Value incl)
Method for setting default POJO property inclusion strategy for serialization,
applied for all properties for which there are no per-type or per-property
overrides (via annotations or config overrides).
|
ObjectMapper |
setDefaultSetterInfo(JsonSetter.Value v)
Method for setting default Setter configuration, regarding things like
merging, null-handling; used for properties for which there are
no per-type or per-property overrides (via annotations or config overrides).
|
ObjectMapper |
setDefaultTyping(TypeResolverBuilder<?> typer)
Method for enabling automatic inclusion of type information ("Default Typing"),
using specified handler object for determining which types this affects,
as well as details of how information is embedded.
|
ObjectMapper |
setDefaultVisibility(JsonAutoDetect.Value vis)
Method for setting auto-detection visibility definition
defaults, which are in effect unless overridden by
annotations (like
JsonAutoDetect ) or per-type
visibility overrides. |
ObjectMapper |
setFilterProvider(FilterProvider filterProvider)
Method for configuring this mapper to use specified
FilterProvider for
mapping Filter Ids to actual filter instances. |
void |
setFilters(FilterProvider filterProvider)
Deprecated.
Since 2.6, use
setFilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider) instead (allows chaining) |
Object |
setHandlerInstantiator(HandlerInstantiator hi)
Method for configuring
HandlerInstantiator to use for creating
instances of handlers (such as serializers, deserializers, type and type
id resolvers), given a class. |
ObjectMapper |
setInjectableValues(InjectableValues injectableValues)
Method for configuring
InjectableValues which used to find
values to inject. |
ObjectMapper |
setLocale(Locale l)
Method for overriding default locale to use for formatting.
|
void |
setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
Deprecated.
Since 2.5: replaced by a fluent form of the method;
setMixIns(java.util.Map<java.lang.Class<?>, java.lang.Class<?>>) . |
ObjectMapper |
setMixInResolver(ClassIntrospector.MixInResolver resolver)
Method that can be called to specify given resolver for locating
mix-in classes to use, overriding directly added mappings.
|
ObjectMapper |
setMixIns(Map<Class<?>,Class<?>> sourceMixins)
Method to use for defining mix-in annotations to use for augmenting
annotations that processable (serializable / deserializable)
classes have.
|
ObjectMapper |
setNodeFactory(JsonNodeFactory f)
Method for specifying
JsonNodeFactory to use for
constructing root level tree nodes (via method
createObjectNode() |
ObjectMapper |
setPolymorphicTypeValidator(PolymorphicTypeValidator ptv)
Method for specifying
PolymorphicTypeValidator to use for validating
polymorphic subtypes used with explicit polymorphic types (annotation-based),
but NOT one with "default typing" (see activateDefaultTyping(PolymorphicTypeValidator)
for details). |
ObjectMapper |
setPropertyInclusion(JsonInclude.Value incl)
Deprecated.
|
ObjectMapper |
setPropertyNamingStrategy(PropertyNamingStrategy s)
Method for setting custom property naming strategy to use.
|
ObjectMapper |
setSerializationInclusion(JsonInclude.Include incl)
Convenience method, equivalent to calling:
|
ObjectMapper |
setSerializerFactory(SerializerFactory f)
Method for setting specific
SerializerFactory to use
for constructing (bean) serializers. |
ObjectMapper |
setSerializerProvider(DefaultSerializerProvider p)
Method for setting "blueprint"
SerializerProvider instance
to use as the base for actual provider instances to use for handling
caching of JsonSerializer instances. |
ObjectMapper |
setSubtypeResolver(SubtypeResolver str)
Method for setting custom subtype resolver to use.
|
ObjectMapper |
setTimeZone(TimeZone tz)
Method for overriding default TimeZone to use for formatting.
|
ObjectMapper |
setTypeFactory(TypeFactory f)
Method that can be used to override
TypeFactory instance
used by this mapper. |
ObjectMapper |
setVisibility(PropertyAccessor forMethod,
JsonAutoDetect.Visibility visibility)
Convenience method that allows changing configuration for
underlying
VisibilityChecker s, to change details of what kinds of
properties are auto-detected. |
ObjectMapper |
setVisibility(VisibilityChecker<?> vc)
Method for setting currently configured default
VisibilityChecker ,
object used for determining whether given property element
(method, field, constructor) can be auto-detected or not. |
void |
setVisibilityChecker(VisibilityChecker<?> vc)
Deprecated.
Since 2.6 use
setVisibility(VisibilityChecker) instead. |
JsonFactory |
tokenStreamFactory()
Method that can be used to get hold of
JsonFactory that this
mapper uses if it needs to construct JsonParser s
and/or JsonGenerator s. |
JsonParser |
treeAsTokens(TreeNode n)
Method for constructing a
JsonParser out of JSON tree
representation. |
<T> T |
treeToValue(TreeNode n,
Class<T> valueType)
Convenience conversion method that will bind data given JSON tree
contains into specific value (usually bean) type.
|
<T> T |
treeToValue(TreeNode n,
JavaType valueType)
Same as
treeToValue(TreeNode, Class) but target type specified
using fully resolved JavaType . |
<T> T |
updateValue(T valueToUpdate,
Object overrides)
Convenience method similar to
convertValue(Object, JavaType) but one
in which |
<T extends JsonNode> |
valueToTree(Object fromValue)
Method that is reverse of
treeToValue(com.fasterxml.jackson.core.TreeNode, java.lang.Class<T>) : it
will convert given Java value (usually bean) into its
equivalent Tree mode JsonNode representation. |
Version |
version()
Method that will return version information stored in and read from jar
that contains this class.
|
ObjectWriter |
writer()
Convenience method for constructing
ObjectWriter
with default settings. |
ObjectWriter |
writer(Base64Variant defaultBase64)
Factory method for constructing
ObjectWriter that will
use specified Base64 encoding variant for Base64-encoded binary data. |
ObjectWriter |
writer(CharacterEscapes escapes)
Factory method for constructing
ObjectReader that will
use specified character escaping details for output. |
ObjectWriter |
writer(ContextAttributes attrs)
Factory method for constructing
ObjectWriter that will
use specified default attributes. |
ObjectWriter |
writer(DateFormat df)
Factory method for constructing
ObjectWriter that will
serialize objects using specified DateFormat ; or, if
null passed, using timestamp (64-bit number. |
ObjectWriter |
writer(FilterProvider filterProvider)
Factory method for constructing
ObjectWriter that will
serialize objects using specified filter provider. |
ObjectWriter |
writer(FormatSchema schema)
Factory method for constructing
ObjectWriter that will
pass specific schema object to JsonGenerator used for
writing content. |
ObjectWriter |
writer(PrettyPrinter pp)
Factory method for constructing
ObjectWriter that will
serialize objects using specified pretty printer for indentation
(or if null, no pretty printer) |
ObjectWriter |
writer(SerializationFeature feature)
Factory method for constructing
ObjectWriter with
specified feature enabled (compared to settings that this
mapper instance has). |
ObjectWriter |
writer(SerializationFeature first,
SerializationFeature... other)
Factory method for constructing
ObjectWriter with
specified features enabled (compared to settings that this
mapper instance has). |
ObjectWriter |
writerFor(Class<?> rootType)
Factory method for constructing
ObjectWriter that will
serialize objects using specified root type, instead of actual
runtime type of value. |
ObjectWriter |
writerFor(JavaType rootType)
Factory method for constructing
ObjectWriter that will
serialize objects using specified root type, instead of actual
runtime type of value. |
ObjectWriter |
writerFor(TypeReference<?> rootType)
Factory method for constructing
ObjectWriter that will
serialize objects using specified root type, instead of actual
runtime type of value. |
ObjectWriter |
writerWithDefaultPrettyPrinter()
Factory method for constructing
ObjectWriter that will
serialize objects using the default pretty printer for indentation |
ObjectWriter |
writerWithType(Class<?> rootType)
Deprecated.
Since 2.5, use
writerFor(Class) instead |
ObjectWriter |
writerWithType(JavaType rootType)
Deprecated.
Since 2.5, use
writerFor(JavaType) instead |
ObjectWriter |
writerWithType(TypeReference<?> rootType)
Deprecated.
Since 2.5, use
writerFor(TypeReference) instead |
ObjectWriter |
writerWithView(Class<?> serializationView)
Factory method for constructing
ObjectWriter that will
serialize objects using specified JSON View (filter). |
void |
writeTree(JsonGenerator g,
JsonNode rootNode)
Method to serialize given JSON Tree, using generator
provided.
|
void |
writeTree(JsonGenerator g,
TreeNode rootNode) |
void |
writeValue(DataOutput out,
Object value) |
void |
writeValue(File resultFile,
Object value)
Method that can be used to serialize any Java value as
JSON output, written to File provided.
|
void |
writeValue(JsonGenerator g,
Object value)
Method that can be used to serialize any Java value as
JSON output, using provided
JsonGenerator . |
void |
writeValue(OutputStream out,
Object value)
Method that can be used to serialize any Java value as
JSON output, using output stream provided (using encoding
JsonEncoding.UTF8 ). |
void |
writeValue(Writer w,
Object value)
Method that can be used to serialize any Java value as
JSON output, using Writer provided.
|
byte[] |
writeValueAsBytes(Object value)
Method that can be used to serialize any Java value as
a byte array.
|
String |
writeValueAsString(Object value)
Method that can be used to serialize any Java value as
a String.
|
getJsonFactory
protected static final AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR
protected static final BaseSettings DEFAULT_BASE
ObjectMapper
instances.protected final JsonFactory _jsonFactory
JsonParser
and JsonGenerator
instances as necessary.protected TypeFactory _typeFactory
JavaType
instances;
needed to allow modules to add more custom type handling
(mostly to support types of non-Java JVM languages)protected InjectableValues _injectableValues
protected SubtypeResolver _subtypeResolver
protected final ConfigOverrides _configOverrides
protected final CoercionConfigs _coercionConfigs
protected SimpleMixInResolver _mixIns
Annotations associated with the value classes will be used to override annotations of the key class, associated with the same field or method. They can be further masked by sub-classes: you can think of it as injecting annotations between the target class and its sub-classes (or interfaces)
Map
protected SerializationConfig _serializationConfig
protected DefaultSerializerProvider _serializerProvider
_serializerFactory
to allow
for constructing custom serializers.
Note: while serializers are only exposed SerializerProvider
,
mappers and readers need to access additional API defined by
DefaultSerializerProvider
protected SerializerFactory _serializerFactory
protected DeserializationConfig _deserializationConfig
protected DefaultDeserializationContext _deserializationContext
protected Set<Object> _registeredModuleTypes
Module.getTypeId()
that have been
registered; kept track of iff MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS
is enabled, so that duplicate registration calls can be ignored
(to avoid adding same handlers multiple times, mostly).protected final ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _rootDeserializers
Given that we don't expect much concurrency for additions (should very quickly converge to zero after startup), let's explicitly define a low concurrency setting.
These may are either "raw" deserializers (when no type information is needed for base type), or type-wrapped deserializers (if it is needed)
public ObjectMapper()
JsonFactory
as necessary, use
SerializerProvider
as its
SerializerProvider
, and
BeanSerializerFactory
as its
SerializerFactory
.
This means that it
can serialize all standard JDK types, as well as regular
Java Beans (based on method names and Jackson-specific annotations),
but does not support JAXB annotations.public ObjectMapper(JsonFactory jf)
JsonFactory
for constructing necessary JsonParser
s and/or
JsonGenerator
s.protected ObjectMapper(ObjectMapper src)
copy()
.public ObjectMapper(JsonFactory jf, DefaultSerializerProvider sp, DefaultDeserializationContext dc)
JsonFactory
for constructing necessary JsonParser
s and/or
JsonGenerator
s, and uses given providers for accessing
serializers and deserializers.jf
- JsonFactory to use: if null, a new MappingJsonFactory
will be constructedsp
- SerializerProvider to use: if null, a SerializerProvider
will be constructeddc
- Blueprint deserialization context instance to use for creating
actual context objects; if null, will construct standard
DeserializationContext
protected ClassIntrospector defaultClassIntrospector()
ClassIntrospector
to use.public ObjectMapper copy()
ObjectMapper
instance that
has same initial configuration as this instance. Note that this
also requires making a copy of the underlying JsonFactory
instance.
Method is typically used when multiple, differently configured mappers are needed. Although configuration is shared, cached serializers and deserializers are NOT shared, which means that the new instance may be re-configured before use; meaning that it behaves the same way as if an instance was constructed from scratch.
protected void _checkInvalidCopy(Class<?> exp)
protected ObjectReader _newReader(DeserializationConfig config)
ObjectReader
instances of proper sub-typeprotected ObjectReader _newReader(DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues)
ObjectReader
instances of proper sub-typeprotected ObjectWriter _newWriter(SerializationConfig config)
ObjectWriter
instances of proper sub-typeprotected ObjectWriter _newWriter(SerializationConfig config, FormatSchema schema)
ObjectWriter
instances of proper sub-typeprotected ObjectWriter _newWriter(SerializationConfig config, JavaType rootType, PrettyPrinter pp)
ObjectWriter
instances of proper sub-typepublic Version version()
version
in interface Versioned
version
in class ObjectCodec
public ObjectMapper registerModule(Module module)
module
- Module to registerpublic ObjectMapper registerModules(Module... modules)
for (Module module : modules) { registerModule(module); }
public ObjectMapper registerModules(Iterable<? extends Module> modules)
for (Module module : modules) { registerModule(module); }
public Set<Object> getRegisteredModuleIds()
Module
typeIds that are registered in this
ObjectMapper, if (and only if!)
MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS
is enabled AND module being added returns non-null
value
for its Module.getTypeId()
.
NOTE: when using the default SimpleModule
constructor, its id is specified as null
and as a consequence such
module is NOT included in returned set.
public static List<Module> findModules()
ServiceLoader
facility, along with module-provided SPI.
Note that method does not do any caching, so calls should be considered potentially expensive.
public static List<Module> findModules(ClassLoader classLoader)
ServiceLoader
facility, along with module-provided SPI.
Note that method does not do any caching, so calls should be considered potentially expensive.
public ObjectMapper findAndRegisterModules()
mapper.registerModules(mapper.findModules());
As with findModules()
, no caching is done for modules, so care
needs to be taken to either create and share a single mapper instance;
or to cache introspected set of modules.
public JsonGenerator createGenerator(OutputStream out) throws IOException
JsonGenerator
to write content using specified OutputStream
.
Generator is not managed (or "owned") by mapper: caller is responsible
for properly closing it once content generation is complete.IOException
public JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException
JsonGenerator
to write content using specified OutputStream
and encoding.
Generator is not managed (or "owned") by mapper: caller is responsible
for properly closing it once content generation is complete.IOException
public JsonGenerator createGenerator(Writer w) throws IOException
JsonGenerator
to write content using specified Writer
.
Generator is not managed (or "owned") by mapper: caller is responsible
for properly closing it once content generation is complete.IOException
public JsonGenerator createGenerator(File outputFile, JsonEncoding enc) throws IOException
JsonGenerator
to write content to specified File
, using specified encoding.
Generator is not managed (or "owned") by mapper: caller is responsible
for properly closing it once content generation is complete.IOException
public JsonGenerator createGenerator(DataOutput out) throws IOException
JsonGenerator
to write content using specified DataOutput
.
Generator is not managed (or "owned") by mapper: caller is responsible
for properly closing it once content generation is complete.IOException
public JsonParser createParser(File src) throws IOException
JsonParser
to read content from specified File
.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(URL src) throws IOException
JsonParser
to read content from specified File
.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(InputStream in) throws IOException
JsonParser
to read content using specified InputStream
.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(Reader r) throws IOException
JsonParser
to read content using specified Reader
.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(byte[] content) throws IOException
JsonParser
to read content from specified byte array.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(byte[] content, int offset, int len) throws IOException
JsonParser
to read content from specified byte array.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(String content) throws IOException
JsonParser
to read content from specified String.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(char[] content) throws IOException
JsonParser
to read content from specified character array
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(char[] content, int offset, int len) throws IOException
JsonParser
to read content from specified character array.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createParser(DataInput content) throws IOException
JsonParser
to read content using specified DataInput
.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public JsonParser createNonBlockingByteArrayParser() throws IOException
JsonParser
to read content using non-blocking (asynchronous) mode.
Parser is not managed (or "owned") by ObjectMapper: caller is responsible
for properly closing it once content reading is complete.IOException
public SerializationConfig getSerializationConfig()
SerializationConfig
object that defines configuration settings for serialization.
Note that since instances are immutable, you can NOT change settings by accessing an instance and calling methods: this will simply create new instance of config object.
public DeserializationConfig getDeserializationConfig()
DeserializationConfig
object
that defines configuration settings for deserialization.
Note that since instances are immutable, you can NOT change settings by accessing an instance and calling methods: this will simply create new instance of config object.
public DeserializationContext getDeserializationContext()
DeserializationContext
.
Note that since instances are immutable, you can NOT change settings by accessing an instance and calling methods: this will simply create new instance of context object.
public ObjectMapper setSerializerFactory(SerializerFactory f)
SerializerFactory
to use
for constructing (bean) serializers.public SerializerFactory getSerializerFactory()
SerializerFactory
.
Note that since instances are immutable, you can NOT change settings by accessing an instance and calling methods: this will simply create new instance of factory object.
public ObjectMapper setSerializerProvider(DefaultSerializerProvider p)
SerializerProvider
instance
to use as the base for actual provider instances to use for handling
caching of JsonSerializer
instances.public SerializerProvider getSerializerProvider()
DefaultSerializerProvider.createInstance(com.fasterxml.jackson.databind.SerializationConfig, com.fasterxml.jackson.databind.ser.SerializerFactory)
.
Note that returned instance cannot be directly used as it is not properly
configured: to get a properly configured instance to call, use
getSerializerProviderInstance()
instead.public SerializerProvider getSerializerProviderInstance()
SerializerProvider
instance that may be used for accessing serializers. This is same as
calling getSerializerProvider()
, and calling createInstance
on it.public ObjectMapper setMixIns(Map<Class<?>,Class<?>> sourceMixins)
Note that this method will CLEAR any previously defined mix-ins for this mapper.
public ObjectMapper addMixIn(Class<?> target, Class<?> mixinSource)
mixinSource
are taken to override annotations
that target
(or its supertypes) has.target
- Class (or interface) whose annotations to effectively overridemixinSource
- Class (or interface) whose annotations are to
be "added" to target's annotations, overriding as necessarypublic ObjectMapper setMixInResolver(ClassIntrospector.MixInResolver resolver)
public int mixInCount()
@Deprecated public void setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
setMixIns(java.util.Map<java.lang.Class<?>, java.lang.Class<?>>)
.@Deprecated public final void addMixInAnnotations(Class<?> target, Class<?> mixinSource)
addMixIn(Class, Class)
.public VisibilityChecker<?> getVisibilityChecker()
public ObjectMapper setVisibility(VisibilityChecker<?> vc)
VisibilityChecker
,
object used for determining whether given property element
(method, field, constructor) can be auto-detected or not.
This default checker is used as the base visibility:
per-class overrides (both via annotations and per-type config overrides)
can further change these settings.public ObjectMapper setVisibility(PropertyAccessor forMethod, JsonAutoDetect.Visibility visibility)
VisibilityChecker
s, to change details of what kinds of
properties are auto-detected.
Basically short cut for doing:
mapper.setVisibilityChecker( mapper.getVisibilityChecker().withVisibility(forMethod, visibility) );one common use case would be to do:
mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY);which would make all member fields serializable without further annotations, instead of just public fields (default setting).
forMethod
- Type of property descriptor affected (field, getter/isGetter,
setter, creator)visibility
- Minimum visibility to require for the property descriptors of typepublic SubtypeResolver getSubtypeResolver()
public ObjectMapper setSubtypeResolver(SubtypeResolver str)
public ObjectMapper setAnnotationIntrospector(AnnotationIntrospector ai)
AnnotationIntrospector
used by this
mapper instance for both serialization and deserialization.
Note that doing this will replace the current introspector, which
may lead to unavailability of core Jackson annotations.
If you want to combine handling of multiple introspectors,
have a look at AnnotationIntrospectorPair
.AnnotationIntrospectorPair
public ObjectMapper setAnnotationIntrospectors(AnnotationIntrospector serializerAI, AnnotationIntrospector deserializerAI)
AnnotationIntrospector
instances used
by this mapper instance for serialization and deserialization,
specifying them separately so that different introspection can be
used for different aspectsserializerAI
- AnnotationIntrospector
to use for configuring
serializationdeserializerAI
- AnnotationIntrospector
to use for configuring
deserializationAnnotationIntrospectorPair
public ObjectMapper setPropertyNamingStrategy(PropertyNamingStrategy s)
public PropertyNamingStrategy getPropertyNamingStrategy()
public ObjectMapper setAccessorNaming(AccessorNamingStrategy.Provider s)
public ObjectMapper setDefaultPrettyPrinter(PrettyPrinter pp)
PrettyPrinter
to use when "default pretty-printing"
is enabled (by enabling SerializationFeature.INDENT_OUTPUT
)pp
- Pretty printer to use by default.@Deprecated public void setVisibilityChecker(VisibilityChecker<?> vc)
setVisibility(VisibilityChecker)
instead.public ObjectMapper setPolymorphicTypeValidator(PolymorphicTypeValidator ptv)
PolymorphicTypeValidator
to use for validating
polymorphic subtypes used with explicit polymorphic types (annotation-based),
but NOT one with "default typing" (see activateDefaultTyping(PolymorphicTypeValidator)
for details).public PolymorphicTypeValidator getPolymorphicTypeValidator()
PolymorphicTypeValidator
used for validating
polymorphic subtypes used with explicit polymorphic types (annotation-based),
but NOT one with "default typing" (see activateDefaultTyping(PolymorphicTypeValidator)
for details).public ObjectMapper setSerializationInclusion(JsonInclude.Include incl)
setPropertyInclusion(JsonInclude.Value.construct(incl, incl));
NOTE: behavior differs slightly from 2.8, where second argument was
implied to be JsonInclude.Include.ALWAYS
.
@Deprecated public ObjectMapper setPropertyInclusion(JsonInclude.Value incl)
setDefaultPropertyInclusion(com.fasterxml.jackson.annotation.JsonInclude.Value)
public ObjectMapper setDefaultPropertyInclusion(JsonInclude.Value incl)
setPropertyInclusion
)public ObjectMapper setDefaultPropertyInclusion(JsonInclude.Include incl)
setDefaultPropertyInclusion(JsonInclude.Value.construct(incl, incl));
setPropertyInclusion
)public ObjectMapper setDefaultSetterInfo(JsonSetter.Value v)
public ObjectMapper setDefaultVisibility(JsonAutoDetect.Value vis)
JsonAutoDetect
) or per-type
visibility overrides.public ObjectMapper setDefaultMergeable(Boolean b)
public ObjectMapper setDefaultLeniency(Boolean b)
public void registerSubtypes(Class<?>... classes)
public void registerSubtypes(NamedType... types)
public void registerSubtypes(Collection<Class<?>> subtypes)
public ObjectMapper activateDefaultTyping(PolymorphicTypeValidator ptv)
activateDefaultTyping(ptv, DefaultTyping.OBJECT_AND_NON_CONCRETE);
NOTE: choice of PolymorphicTypeValidator
to pass is critical for security
as allowing all subtypes can be risky for untrusted content.
ptv
- Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized.public ObjectMapper activateDefaultTyping(PolymorphicTypeValidator ptv, ObjectMapper.DefaultTyping applicability)
activateDefaultTyping(ptv, dti, JsonTypeInfo.As.WRAPPER_ARRAY);
NOTE: choice of PolymorphicTypeValidator
to pass is critical for security
as allowing all subtypes can be risky for untrusted content.
ptv
- Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized.applicability
- Defines kinds of types for which additional type information
is added; see ObjectMapper.DefaultTyping
for more information.public ObjectMapper activateDefaultTyping(PolymorphicTypeValidator ptv, ObjectMapper.DefaultTyping applicability, JsonTypeInfo.As includeAs)
JsonTypeInfo
).
NOTE: use of JsonTypeInfo.As#EXTERNAL_PROPERTY
NOT SUPPORTED;
and attempts of do so will throw an IllegalArgumentException
to make
this limitation explicit.
NOTE: choice of PolymorphicTypeValidator
to pass is critical for security
as allowing all subtypes can be risky for untrusted content.
ptv
- Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized.applicability
- Defines kinds of types for which additional type information
is added; see ObjectMapper.DefaultTyping
for more information.includeAs
- public ObjectMapper activateDefaultTypingAsProperty(PolymorphicTypeValidator ptv, ObjectMapper.DefaultTyping applicability, String propertyName)
JsonTypeInfo
) --
using "As.PROPERTY" inclusion mechanism and specified property name
to use for inclusion (default being "@class" since default type information
always uses class name as type identifier)
NOTE: choice of PolymorphicTypeValidator
to pass is critical for security
as allowing all subtypes can be risky for untrusted content.
ptv
- Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized.applicability
- Defines kinds of types for which additional type information
is added; see ObjectMapper.DefaultTyping
for more information.propertyName
- Name of property used for including type id for polymorphic values.public ObjectMapper deactivateDefaultTyping()
JsonTypeInfo
) will have
additional embedded type information.public ObjectMapper setDefaultTyping(TypeResolverBuilder<?> typer)
NOTE: use of Default Typing can be a potential security risk if incoming
content comes from untrusted sources, so care should be taken to use
a TypeResolverBuilder
that can limit allowed classes to
deserialize. Note in particular that
StdTypeResolverBuilder
DOES NOT limit applicability but creates type (de)serializers for all
types.
typer
- Type information inclusion handler@Deprecated public ObjectMapper enableDefaultTyping()
activateDefaultTyping(PolymorphicTypeValidator)
instead@Deprecated public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping dti)
activateDefaultTyping(PolymorphicTypeValidator,DefaultTyping)
instead@Deprecated public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping applicability, JsonTypeInfo.As includeAs)
activateDefaultTyping(PolymorphicTypeValidator,DefaultTyping,JsonTypeInfo.As)
instead@Deprecated public ObjectMapper enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping applicability, String propertyName)
activateDefaultTypingAsProperty(PolymorphicTypeValidator,DefaultTyping,String)
instead@Deprecated public ObjectMapper disableDefaultTyping()
deactivateDefaultTyping()
insteadpublic MutableConfigOverride configOverride(Class<?> type)
mapper.configOverride(java.util.Date.class) .setFormat(JsonFormat.Value.forPattern("yyyy-MM-dd"));to change the default format to use for properties of type
Date
(possibly further overridden by per-property
annotations)public MutableCoercionConfig coercionConfigDefaults()
MutableCoercionConfig
through which
default (fallback) coercion configurations can be changed.
Note that such settings are only applied if more specific
(by logical and physical type) configuration have
not been defined.public MutableCoercionConfig coercionConfigFor(LogicalType logicalType)
MutableCoercionConfig
through which
coercion configuration for specified logical target type can be set.public MutableCoercionConfig coercionConfigFor(Class<?> physicalType)
MutableCoercionConfig
through which
coercion configuration for specified physical target type can be set.public TypeFactory getTypeFactory()
TypeFactory
instance.public ObjectMapper setTypeFactory(TypeFactory f)
TypeFactory
instance
used by this mapper.
Note: will also set TypeFactory
that deserialization and
serialization config objects use.
public JavaType constructType(Type t)
JavaType
out of given
type (typically java.lang.Class
), but without explicit
context.public JavaType constructType(TypeReference<?> typeRef)
JavaType
out of given
type reference.public JsonNodeFactory getNodeFactory()
JsonNodeFactory
that this mapper will use when directly constructing
root JsonNode
instances for Trees.
Note: this is just a shortcut for calling
getDeserializationConfig().getNodeFactory()
public ObjectMapper setNodeFactory(JsonNodeFactory f)
JsonNodeFactory
to use for
constructing root level tree nodes (via method
createObjectNode()
public ObjectMapper setConstructorDetector(ConstructorDetector cd)
ConstructorDetector
to use for
determining some aspects of creator auto-detection (specifically
auto-detection of constructor, and in particular behavior with
single-argument constructors).public ObjectMapper addHandler(DeserializationProblemHandler h)
DeserializationProblemHandler
to be used for handling specific problems during deserialization.public ObjectMapper clearProblemHandlers()
DeserializationProblemHandler
s
instances from this mapper.public ObjectMapper setConfig(DeserializationConfig config)
DeserializationConfig
object.
It is added as a fallback method that may be used if no other configuration
modifier method works: it should not be used if there are alternatives,
and its use is generally discouraged.
NOTE: only use this method if you know what you are doing -- it allows
by-passing some of checks applied to other configuration methods.
Also keep in mind that as with all configuration of ObjectMapper
,
this is only thread-safe if done before calling any deserialization methods.
@Deprecated public void setFilters(FilterProvider filterProvider)
setFilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider)
instead (allows chaining)public ObjectMapper setFilterProvider(FilterProvider filterProvider)
FilterProvider
for
mapping Filter Ids to actual filter instances.
Note that usually it is better to use method writer(FilterProvider)
;
however, sometimes
this method is more convenient. For example, some frameworks only allow configuring
of ObjectMapper instances and not ObjectWriter
s.
public ObjectMapper setBase64Variant(Base64Variant v)
Base64Variant
that
byte[]
serializers and deserializers will use.v
- Base64 variant to usepublic ObjectMapper setConfig(SerializationConfig config)
SerializationConfig
object, which contains serialization-specific configuration settings.
It is added as a fallback method that may be used if no other configuration
modifier method works: it should not be used if there are alternatives,
and its use is generally discouraged.
NOTE: only use this method if you know what you are doing -- it allows
by-passing some of checks applied to other configuration methods.
Also keep in mind that as with all configuration of ObjectMapper
,
this is only thread-safe if done before calling any serialization methods.
public JsonFactory tokenStreamFactory()
JsonFactory
that this
mapper uses if it needs to construct JsonParser
s
and/or JsonGenerator
s.
WARNING: note that all ObjectReader
and ObjectWriter
instances created by this mapper usually share the same configured
JsonFactory
, so changes to its configuration will "leak".
To avoid such observed changes you should always use "with()" and
"without()" method of ObjectReader
and ObjectWriter
for changing JsonParser.Feature
and JsonGenerator.Feature
settings to use on per-call basis.
JsonFactory
that this mapper uses when it needs to
construct Json parser and generatorspublic JsonFactory getFactory()
getFactory
in class ObjectCodec
public ObjectMapper setDateFormat(DateFormat dateFormat)
DateFormat
to use when serializing time
values as Strings, and deserializing from JSON Strings.
This is preferably to directly modifying SerializationConfig
and
DeserializationConfig
instances.
If you need per-request configuration, use writer(DateFormat)
to
create properly configured ObjectWriter
and use that; this because
ObjectWriter
s are thread-safe whereas ObjectMapper itself is only
thread-safe when configuring methods (such as this one) are NOT called.public DateFormat getDateFormat()
public Object setHandlerInstantiator(HandlerInstantiator hi)
HandlerInstantiator
to use for creating
instances of handlers (such as serializers, deserializers, type and type
id resolvers), given a class.hi
- Instantiator to use; if null, use the default implementationpublic ObjectMapper setInjectableValues(InjectableValues injectableValues)
InjectableValues
which used to find
values to inject.public InjectableValues getInjectableValues()
public ObjectMapper setLocale(Locale l)
Locale.getDefault()
.public ObjectMapper setTimeZone(TimeZone tz)
public ObjectMapper setDefaultAttributes(ContextAttributes attrs)
NOTE: preferred way to set the defaults is to use Builder
style
construction, see JsonMapper.builder()
(and MapperBuilder.defaultAttributes(com.fasterxml.jackson.databind.cfg.ContextAttributes)
).
public boolean isEnabled(MapperFeature f)
MapperFeature
is enabled.@Deprecated public ObjectMapper configure(MapperFeature f, boolean state)
JsonMapper.builder().configure(...)
@Deprecated public ObjectMapper enable(MapperFeature... f)
JsonMapper.builder().enable(...)
@Deprecated public ObjectMapper disable(MapperFeature... f)
JsonMapper.builder().disable(...)
public boolean isEnabled(SerializationFeature f)
public ObjectMapper configure(SerializationFeature f, boolean state)
public ObjectMapper enable(SerializationFeature f)
DeserializationConfig
feature.
Modifies and returns this instance; no new object is created.public ObjectMapper enable(SerializationFeature first, SerializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.public ObjectMapper disable(SerializationFeature f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.public ObjectMapper disable(SerializationFeature first, SerializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.public boolean isEnabled(DeserializationFeature f)
public ObjectMapper configure(DeserializationFeature f, boolean state)
public ObjectMapper enable(DeserializationFeature feature)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.public ObjectMapper enable(DeserializationFeature first, DeserializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.public ObjectMapper disable(DeserializationFeature feature)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.public ObjectMapper disable(DeserializationFeature first, DeserializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.public boolean isEnabled(JsonParser.Feature f)
public ObjectMapper configure(JsonParser.Feature f, boolean state)
JsonParser.Feature
s
for parser instances this object mapper creates.
Note that this is equivalent to directly calling same method
on getFactory()
.
WARNING: since this method directly modifies state of underlying JsonFactory
,
it will change observed configuration by ObjectReader
s as well -- to avoid
this, use ObjectReader.with(JsonParser.Feature)
instead.
public ObjectMapper enable(JsonParser.Feature... features)
JsonParser.Feature
s
for parser instances this object mapper creates.
Note that this is equivalent to directly calling same method on getFactory()
.
WARNING: since this method directly modifies state of underlying JsonFactory
,
it will change observed configuration by ObjectReader
s as well -- to avoid
this, use ObjectReader.with(JsonParser.Feature)
instead.
public ObjectMapper disable(JsonParser.Feature... features)
JsonParser.Feature
s
for parser instances this object mapper creates.
Note that this is equivalent to directly calling same method on getFactory()
.
WARNING: since this method directly modifies state of underlying JsonFactory
,
it will change observed configuration by ObjectReader
s as well -- to avoid
this, use ObjectReader.without(JsonParser.Feature)
instead.
public boolean isEnabled(JsonGenerator.Feature f)
public ObjectMapper configure(JsonGenerator.Feature f, boolean state)
JsonGenerator
feature for
generator instances this object mapper creates.
Note that this is equivalent to directly calling same method
on getFactory()
.
WARNING: since this method directly modifies state of underlying JsonFactory
,
it will change observed configuration by ObjectWriter
s as well -- to avoid
this, use ObjectWriter.with(JsonGenerator.Feature)
instead.
public ObjectMapper enable(JsonGenerator.Feature... features)
JsonGenerator.Feature
s
for parser instances this object mapper creates.
Note that this is equivalent to directly calling same method on getFactory()
.
WARNING: since this method directly modifies state of underlying JsonFactory
,
it will change observed configuration by ObjectWriter
s as well -- to avoid
this, use ObjectWriter.with(JsonGenerator.Feature)
instead.
public ObjectMapper disable(JsonGenerator.Feature... features)
JsonGenerator.Feature
s
for parser instances this object mapper creates.
Note that this is equivalent to directly calling same method on getFactory()
.
WARNING: since this method directly modifies state of underlying JsonFactory
,
it will change observed configuration by ObjectWriter
s as well -- to avoid
this, use ObjectWriter.without(JsonGenerator.Feature)
instead.
public boolean isEnabled(JsonFactory.Feature f)
getFactory().isEnabled(f);
public boolean isEnabled(StreamReadFeature f)
public boolean isEnabled(StreamWriteFeature f)
public <T> T readValue(JsonParser p, Class<T> valueType) throws IOException, StreamReadException, DatabindException
Boolean
).
Note: this method should NOT be used if the result type is a
container (Collection
or Map
.
The reason is that due to type erasure, key and value types
cannot be introspected when using this method.
readValue
in class ObjectCodec
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public <T> T readValue(JsonParser p, TypeReference<T> valueTypeRef) throws IOException, StreamReadException, DatabindException
readValue
in class ObjectCodec
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public final <T> T readValue(JsonParser p, ResolvedType valueType) throws IOException, StreamReadException, DatabindException
TypeFactory
.readValue
in class ObjectCodec
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public <T> T readValue(JsonParser p, JavaType valueType) throws IOException, StreamReadException, DatabindException
readValue(JsonParser, Class)
.IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public <T extends TreeNode> T readTree(JsonParser p) throws IOException
JsonNode
.
Returns JsonNode
that represents the root of the resulting tree, if there
was content to read, or null
if no more content is accessible
via passed JsonParser
.
NOTE! Behavior with end-of-input (no more content) differs between this
readTree
method, and all other methods that take input source: latter
will return "missing node", NOT null
readTree
in class ObjectCodec
JsonNode
, if valid JSON content found; null
if input has no content to bind -- note, however, that if
JSON null
token is found, it will be represented
as a non-null JsonNode
(one that returns true
for JsonNode.isNull()
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)public <T> MappingIterator<T> readValues(JsonParser p, ResolvedType valueType) throws IOException
readerFor(valueType).readValues(p);
Method for reading sequence of Objects from parser stream.
Sequence can be either root-level "unwrapped" sequence (without surrounding
JSON array), or a sequence contained in a JSON Array.
In either case JsonParser
MUST point to the first token of
the first element, OR not point to any token (in which case it is advanced
to the next token). This means, specifically, that for wrapped sequences,
parser MUST NOT point to the surrounding START_ARRAY
(one that
contains values to read) but rather to the token following it which is the first
token of the first value to read.
Note that ObjectReader
has more complete set of variants.
readValues
in class ObjectCodec
IOException
public <T> MappingIterator<T> readValues(JsonParser p, JavaType valueType) throws IOException
readerFor(valueType).readValues(p);
Type-safe overload of readValues(JsonParser, ResolvedType)
.
IOException
public <T> MappingIterator<T> readValues(JsonParser p, Class<T> valueType) throws IOException
readerFor(valueType).readValues(p);
Type-safe overload of readValues(JsonParser, ResolvedType)
.
readValues
in class ObjectCodec
IOException
public <T> MappingIterator<T> readValues(JsonParser p, TypeReference<T> valueTypeRef) throws IOException
readValues
in class ObjectCodec
IOException
public JsonNode readTree(InputStream in) throws IOException
JsonNode
instances.
Returns root of the resulting tree (where root can consist
of just a single node if the current event is a
value event, not container).
If a low-level I/O problem (missing input, network error) occurs,
a IOException
will be thrown.
If a parsing problem occurs (invalid JSON),
StreamReadException
will be thrown.
If no content is found from input (end-of-input), Java
null
will be returned.
in
- Input stream used to read JSON content
for building the JSON tree.JsonNode
, if valid JSON content found; null
if input has no content to bind -- note, however, that if
JSON null
token is found, it will be represented
as a non-null JsonNode
(one that returns true
for JsonNode.isNull()
StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)IOException
public JsonNode readTree(Reader r) throws IOException
readTree(InputStream)
except content accessed through
passed-in Reader
IOException
public JsonNode readTree(String content) throws JsonProcessingException, JsonMappingException
readTree(InputStream)
except content read from
passed-in String
public JsonNode readTree(byte[] content) throws IOException
readTree(InputStream)
except content read from
passed-in byte array.IOException
public JsonNode readTree(byte[] content, int offset, int len) throws IOException
readTree(InputStream)
except content read from
passed-in byte array.IOException
public JsonNode readTree(File file) throws IOException
readTree(InputStream)
except content read from
passed-in File
.IOException
public JsonNode readTree(URL source) throws IOException
readTree(InputStream)
except content read from
passed-in URL
.
NOTE: handling of URL
is delegated to
JsonFactory.createParser(java.net.URL)
and usually simply
calls URL.openStream()
, meaning no special handling
is done. If different HTTP connection options are needed you will need
to create InputStream
separately.
IOException
public void writeValue(JsonGenerator g, Object value) throws IOException, StreamWriteException, DatabindException
JsonGenerator
.writeValue
in class ObjectCodec
IOException
StreamWriteException
DatabindException
public void writeTree(JsonGenerator g, TreeNode rootNode) throws IOException
writeTree
in class ObjectCodec
IOException
public void writeTree(JsonGenerator g, JsonNode rootNode) throws IOException
IOException
public ObjectNode createObjectNode()
Note: return type is co-variant, as basic ObjectCodec abstraction cannot refer to concrete node types (as it's part of core package, whereas impls are part of mapper package)
createObjectNode
in class ObjectCodec
public ArrayNode createArrayNode()
Note: return type is co-variant, as basic ObjectCodec abstraction cannot refer to concrete node types (as it's part of core package, whereas impls are part of mapper package)
createArrayNode
in class ObjectCodec
public JsonNode missingNode()
missingNode
in class TreeCodec
public JsonParser treeAsTokens(TreeNode n)
JsonParser
out of JSON tree
representation.treeAsTokens
in class ObjectCodec
n
- Root node of the tree that resulting parser will read frompublic <T> T treeToValue(TreeNode n, Class<T> valueType) throws IllegalArgumentException, JsonProcessingException
Functionally equivalent to:
objectMapper.convertValue(n, valueClass);
Note: inclusion of throws JsonProcessingException
is not accidental
since while there can be no input decoding problems, it is possible that content
does not match target type: in such case various DatabindException
s
are possible. In addition IllegalArgumentException
is possible in some
cases, depending on whether DeserializationFeature.WRAP_EXCEPTIONS
is enabled or not.
treeToValue
in class ObjectCodec
IllegalArgumentException
JsonProcessingException
public <T> T treeToValue(TreeNode n, JavaType valueType) throws IllegalArgumentException, JsonProcessingException
treeToValue(TreeNode, Class)
but target type specified
using fully resolved JavaType
.IllegalArgumentException
JsonProcessingException
public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException
treeToValue(com.fasterxml.jackson.core.TreeNode, java.lang.Class<T>)
: it
will convert given Java value (usually bean) into its
equivalent Tree mode JsonNode
representation.
Functionally similar to serializing value into token stream and parsing that
stream back as tree model node,
but more efficient as TokenBuffer
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.
T
- Actual node type; usually either basic JsonNode
or
ObjectNode
fromValue
- Java value to convertnull
value node for which JsonNode.isNull()
returns true
.IllegalArgumentException
public boolean canSerialize(Class<?> type)
NOTE: since this method does NOT throw exceptions, but internal
processing may, caller usually has little information as to why
serialization would fail. If you want access to internal Exception
,
call canSerialize(Class, AtomicReference)
instead.
public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause)
canSerialize(Class)
but that can return
actual Throwable
that was thrown when trying to construct
serializer: this may be useful in figuring out what the actual problem is.public boolean canDeserialize(JavaType type)
Exception
being thrown, false
is returned.
NOTE: in case an exception is thrown during course of trying
co construct matching deserializer, it will be effectively swallowed.
If you want access to that exception, call
canDeserialize(JavaType, AtomicReference)
instead.
public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause)
canDeserialize(JavaType)
but that can return
actual Throwable
that was thrown when trying to construct
serializer: this may be useful in figuring out what the actual problem is.public <T> T readValue(File src, Class<T> valueType) throws IOException, StreamReadException, DatabindException
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public <T> T readValue(File src, TypeReference<T> valueTypeRef) throws IOException, StreamReadException, DatabindException
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public <T> T readValue(File src, JavaType valueType) throws IOException, StreamReadException, DatabindException
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public <T> T readValue(URL src, Class<T> valueType) throws IOException, StreamReadException, DatabindException
NOTE: handling of URL
is delegated to
JsonFactory.createParser(java.net.URL)
and usually simply
calls URL.openStream()
, meaning no special handling
is done. If different HTTP connection options are needed you will need
to create InputStream
separately.
IOException
- if a low-level I/O problem (unexpected end-of-input,
network error) occurs (passed through as-is without additional wrapping -- note
that this is one case where DeserializationFeature.WRAP_EXCEPTIONS
does NOT result in wrapping of exception even if enabled)StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)public <T> T readValue(URL src, TypeReference<T> valueTypeRef) throws IOException, StreamReadException, DatabindException
readValue(java.net.URL, Class)
except that target specified by TypeReference
.public <T> T readValue(URL src, JavaType valueType) throws IOException, StreamReadException, DatabindException
readValue(java.net.URL, Class)
except that target specified by JavaType
.public <T> T readValue(String content, Class<T> valueType) throws JsonProcessingException, JsonMappingException
StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)JsonProcessingException
JsonMappingException
public <T> T readValue(String content, TypeReference<T> valueTypeRef) throws JsonProcessingException, JsonMappingException
StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)JsonProcessingException
JsonMappingException
public <T> T readValue(String content, JavaType valueType) throws JsonProcessingException, JsonMappingException
StreamReadException
- if underlying input contains invalid content
of type JsonParser
supports (JSON for default case)DatabindException
- if the input JSON structure does not match structure
expected for result type (or has other mismatch issues)JsonProcessingException
JsonMappingException
public <T> T readValue(Reader src, Class<T> valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(Reader src, TypeReference<T> valueTypeRef) throws IOException, StreamReadException, DatabindException
public <T> T readValue(Reader src, JavaType valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(InputStream src, TypeReference<T> valueTypeRef) throws IOException, StreamReadException, DatabindException
public <T> T readValue(InputStream src, JavaType valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(byte[] src, Class<T> valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(byte[] src, int offset, int len, Class<T> valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(byte[] src, TypeReference<T> valueTypeRef) throws IOException, StreamReadException, DatabindException
public <T> T readValue(byte[] src, int offset, int len, TypeReference<T> valueTypeRef) throws IOException, StreamReadException, DatabindException
public <T> T readValue(byte[] src, JavaType valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(byte[] src, int offset, int len, JavaType valueType) throws IOException, StreamReadException, DatabindException
public <T> T readValue(DataInput src, Class<T> valueType) throws IOException
IOException
public <T> T readValue(DataInput src, JavaType valueType) throws IOException
IOException
public void writeValue(File resultFile, Object value) throws IOException, StreamWriteException, DatabindException
public void writeValue(OutputStream out, Object value) throws IOException, StreamWriteException, DatabindException
JsonEncoding.UTF8
).
Note: method does not close the underlying stream explicitly
here; however, JsonFactory
this mapper uses may choose
to close the stream depending on its settings (by default,
it will try to close it when JsonGenerator
we construct
is closed).
public void writeValue(DataOutput out, Object value) throws IOException
IOException
public void writeValue(Writer w, Object value) throws IOException, StreamWriteException, DatabindException
Note: method does not close the underlying stream explicitly
here; however, JsonFactory
this mapper uses may choose
to close the stream depending on its settings (by default,
it will try to close it when JsonGenerator
we construct
is closed).
public String writeValueAsString(Object value) throws JsonProcessingException
writeValue(Writer,Object)
with StringWriter
and constructing String, but more efficient.
Note: prior to version 2.1, throws clause included IOException
; 2.1 removed it.
JsonProcessingException
public byte[] writeValueAsBytes(Object value) throws JsonProcessingException
writeValue(Writer,Object)
with ByteArrayOutputStream
and getting bytes, but more efficient.
Encoding used will be UTF-8.
Note: prior to version 2.1, throws clause included IOException
; 2.1 removed it.
JsonProcessingException
public ObjectWriter writer()
ObjectWriter
with default settings.public ObjectWriter writer(SerializationFeature feature)
ObjectWriter
with
specified feature enabled (compared to settings that this
mapper instance has).public ObjectWriter writer(SerializationFeature first, SerializationFeature... other)
ObjectWriter
with
specified features enabled (compared to settings that this
mapper instance has).public ObjectWriter writer(DateFormat df)
ObjectWriter
that will
serialize objects using specified DateFormat
; or, if
null passed, using timestamp (64-bit number.public ObjectWriter writerWithView(Class<?> serializationView)
ObjectWriter
that will
serialize objects using specified JSON View (filter).public ObjectWriter writerFor(Class<?> rootType)
ObjectWriter
that will
serialize objects using specified root type, instead of actual
runtime type of value. Type must be a super-type of runtime type.
Main reason for using this method is performance, as writer is able to pre-fetch serializer to use before write, and if writer is used more than once this avoids addition per-value serializer lookups.
public ObjectWriter writerFor(TypeReference<?> rootType)
ObjectWriter
that will
serialize objects using specified root type, instead of actual
runtime type of value. Type must be a super-type of runtime type.
Main reason for using this method is performance, as writer is able to pre-fetch serializer to use before write, and if writer is used more than once this avoids addition per-value serializer lookups.
public ObjectWriter writerFor(JavaType rootType)
ObjectWriter
that will
serialize objects using specified root type, instead of actual
runtime type of value. Type must be a super-type of runtime type.
Main reason for using this method is performance, as writer is able to pre-fetch serializer to use before write, and if writer is used more than once this avoids addition per-value serializer lookups.
public ObjectWriter writer(PrettyPrinter pp)
ObjectWriter
that will
serialize objects using specified pretty printer for indentation
(or if null, no pretty printer)public ObjectWriter writerWithDefaultPrettyPrinter()
ObjectWriter
that will
serialize objects using the default pretty printer for indentationpublic ObjectWriter writer(FilterProvider filterProvider)
ObjectWriter
that will
serialize objects using specified filter provider.public ObjectWriter writer(FormatSchema schema)
ObjectWriter
that will
pass specific schema object to JsonGenerator
used for
writing content.schema
- Schema to pass to generatorpublic ObjectWriter writer(Base64Variant defaultBase64)
ObjectWriter
that will
use specified Base64 encoding variant for Base64-encoded binary data.public ObjectWriter writer(CharacterEscapes escapes)
ObjectReader
that will
use specified character escaping details for output.public ObjectWriter writer(ContextAttributes attrs)
ObjectWriter
that will
use specified default attributes.@Deprecated public ObjectWriter writerWithType(Class<?> rootType)
writerFor(Class)
instead@Deprecated public ObjectWriter writerWithType(TypeReference<?> rootType)
writerFor(TypeReference)
instead@Deprecated public ObjectWriter writerWithType(JavaType rootType)
writerFor(JavaType)
insteadpublic ObjectReader reader()
ObjectReader
with
default settings. Note that the resulting instance is NOT usable as is,
without defining expected value type.public ObjectReader reader(DeserializationFeature feature)
ObjectReader
with
specified feature enabled (compared to settings that this
mapper instance has).
Note that the resulting instance is NOT usable as is,
without defining expected value type.public ObjectReader reader(DeserializationFeature first, DeserializationFeature... other)
ObjectReader
with
specified features enabled (compared to settings that this
mapper instance has).
Note that the resulting instance is NOT usable as is,
without defining expected value type.public ObjectReader readerForUpdating(Object valueToUpdate)
ObjectReader
that will
update given Object (usually Bean, but can be a Collection or Map
as well, but NOT an array) with JSON data. Deserialization occurs
normally except that the root-level value in JSON is not used for
instantiating a new object; instead give updateable object is used
as root.
Runtime type of value object is used for locating deserializer,
unless overridden by other factory methods of ObjectReader
public ObjectReader readerFor(JavaType type)
ObjectReader
that will
read or update instances of specified typepublic ObjectReader readerFor(Class<?> type)
ObjectReader
that will
read or update instances of specified typepublic ObjectReader readerFor(TypeReference<?> type)
ObjectReader
that will
read or update instances of specified typepublic ObjectReader readerForArrayOf(Class<?> type)
ObjectReader
that will
read values of a type List<type>
.
Functionally same as:
readerFor(type[].class);
public ObjectReader readerForListOf(Class<?> type)
ObjectReader
that will
read or update instances of a type List<type>
.
Functionally same as:
readerFor(new TypeReference<List<type>>() { });
public ObjectReader readerForMapOf(Class<?> type)
ObjectReader
that will
read or update instances of a type Map<String, type>
Functionally same as:
readerFor(new TypeReference<Map<String, type>>() { });
public ObjectReader reader(JsonNodeFactory f)
ObjectReader
that will
use specified JsonNodeFactory
for constructing JSON trees.public ObjectReader reader(FormatSchema schema)
ObjectReader
that will
pass specific schema object to JsonParser
used for
reading content.schema
- Schema to pass to parserpublic ObjectReader reader(InjectableValues injectableValues)
ObjectReader
that will
use specified injectable values.injectableValues
- Injectable values to usepublic ObjectReader readerWithView(Class<?> view)
ObjectReader
that will
deserialize objects using specified JSON View (filter).public ObjectReader reader(Base64Variant defaultBase64)
ObjectReader
that will
use specified Base64 encoding variant for Base64-encoded binary data.public ObjectReader reader(ContextAttributes attrs)
ObjectReader
that will
use specified default attributes.@Deprecated public ObjectReader reader(JavaType type)
readerFor(JavaType)
instead@Deprecated public ObjectReader reader(Class<?> type)
readerFor(Class)
instead@Deprecated public ObjectReader reader(TypeReference<?> type)
readerFor(TypeReference)
insteadpublic <T> T convertValue(Object fromValue, Class<T> toValueType) throws IllegalArgumentException
This method is functionally similar to first serializing given value into JSON, and then binding JSON data into value of given type, but should be more efficient since full serialization does not (need to) occur. However, same converters (serializers, deserializers) will be used as for data binding, meaning same object mapper configuration works.
Note that behavior changed slightly between Jackson 2.9 and 2.10 so that whereas earlier some optimizations were used to avoid write/read cycle in case input was of target type, from 2.10 onwards full processing is always performed. See databind#2220 for full details of the change.
Further note that it is possible that in some cases behavior does differ from full serialize-then-deserialize cycle: in most case differences are unintentional (that is, flaws to fix) and should be reported, but the behavior is not guaranteed to be 100% the same: the goal is to allow efficient value conversions for structurally compatible Objects, according to standard Jackson configuration.
Finally, this functionality is not designed to support "advanced" use cases, such as conversion of polymorphic values, or cases where Object Identity is used.
IllegalArgumentException
- If conversion fails due to incompatible type;
if so, root cause will contain underlying checked exception data binding
functionality threwpublic <T> T convertValue(Object fromValue, TypeReference<T> toValueTypeRef) throws IllegalArgumentException
IllegalArgumentException
public <T> T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException
IllegalArgumentException
protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException
writeValue
and
readValue
methods.IllegalArgumentException
public <T> T updateValue(T valueToUpdate, Object overrides) throws JsonMappingException
convertValue(Object, JavaType)
but one
in which
Implementation is approximately as follows:
TokenBuffer
ObjectReader
with `valueToUpdate` (using readerForUpdating(Object)
)
JsonParser
(using TokenBuffer.asParser()
)
ObjectReader.readValue(JsonParser)
.
Note that update is "shallow" in that only first level of properties (or, immediate contents
of container to update) are modified, unless properties themselves indicate that
merging should be applied for contents. Such merging can be specified using
annotations (see JsonMerge
) as well as using "config overrides" (see
configOverride(Class)
and setDefaultMergeable(Boolean)
).
valueToUpdate
- Object to updateoverrides
- Object to conceptually serialize and merge into value to
update; can be thought of as a provider for overrides to apply.JsonMappingException
- if there are structural incompatibilities that prevent update.@Deprecated public JsonSchema generateJsonSchema(Class<?> t) throws JsonMappingException
acceptJsonFormatVisitor(JavaType, JsonFormatVisitorWrapper)
)t
- The class to generate schema forJsonMappingException
public void acceptJsonFormatVisitor(Class<?> type, JsonFormatVisitorWrapper visitor) throws JsonMappingException
This method can be used for things like generating JSON Schema instance for specified type.
type
- Type to generate schema for (possibly with generic signature)JsonMappingException
public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException
Serializer
hierarchy and related properties
This method can be used for things like generating JSON Schema instance for specified type.
type
- Type to generate schema for (possibly with generic signature)JsonMappingException
protected TypeResolverBuilder<?> _constructDefaultTypeResolverBuilder(ObjectMapper.DefaultTyping applicability, PolymorphicTypeValidator ptv)
TypeResolverBuilder
subtypes.protected DefaultSerializerProvider _serializerProvider(SerializationConfig config)
SerializerProvider
to use for serialization.protected final void _writeValueAndClose(JsonGenerator g, Object value) throws IOException
IOException
@Deprecated protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException
_writeValueAndClose(com.fasterxml.jackson.core.JsonGenerator, java.lang.Object)
insteadIOException
protected Object _readValue(DeserializationConfig cfg, JsonParser p, JavaType valueType) throws IOException
IOException
protected Object _readMapAndClose(JsonParser p0, JavaType valueType) throws IOException
IOException
protected JsonNode _readTreeAndClose(JsonParser p0) throws IOException
_readMapAndClose(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.JavaType)
but specialized for JsonNode
reading.IOException
protected DefaultDeserializationContext createDeserializationContext(JsonParser p, DeserializationConfig cfg)
DeserializationContext
for deserializing a single root value.
Can be overridden if a custom context is needed.protected JsonToken _initForReading(JsonParser p, JavaType targetType) throws IOException
IOException
- if the underlying input source has problems during
parsingprotected final void _verifyNoTrailingTokens(JsonParser p, DeserializationContext ctxt, JavaType bindType) throws IOException
IOException
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws DatabindException
DatabindException
protected void _verifySchemaType(FormatSchema schema)
Copyright © 2008–2021 FasterXML. All rights reserved.