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 ObjectReaders, ObjectWriters 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 com.fasterxml.jackson.core.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 ObjectReaders and ObjectWriters 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 of "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).
| Modifier and Type | Class and Description |
|---|---|
| public static class | ObjectMapper.DefaultTypeResolverBuilder
Customized |
| public static enum | ObjectMapper.DefaultTyping
Enumeration used with |
| Modifier and Type | Field and Description |
|---|---|
| protected final CoercionConfigs | _coercionConfigs
Current set of coercion configuration definitions that define allowed (and not allowed) coercions from secondary shapes. |
| protected final 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 final JsonFactory | _jsonFactory
Factory used to create |
| 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 | _registeredModuleTypes
Set of module types (as per |
| protected final ConcurrentHashMap | _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 |
| protected static final AnnotationIntrospector | |
| protected static final BaseSettings | DEFAULT_BASE
Base settings contain defaults used for all |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | ObjectMapper()
Default constructor, which will construct the default
|
| public | ObjectMapper(JsonFactory jf)
Constructs instance that uses specified |
| protected | |
| protected | ObjectMapper(ObjectMapper src, JsonFactory factory)
Copy-constructor, mostly used to support |
| public | ObjectMapper(JsonFactory
JsonFactory to use: if null, a new jf, DefaultSerializerProvider MappingJsonFactory will be constructedSerializerProvider to use: if null, a sp, DefaultDeserializationContext SerializerProvider will be constructedBlueprint deserialization context instance to use for creating
actual context objects; if null, will construct standard
dc)DeserializationContextConstructs instance that uses specified |
| Modifier and Type | Method and Description |
|---|---|
| protected final void | |
| protected void | |
| protected final void | _configAndWriteValue(JsonGenerator g, Object value)
Deprecated
Since 2.11.2 Use
_writeValueAndClose instead
|
| protected TypeResolverBuilder | _constructDefaultTypeResolverBuilder(ObjectMapper.
Overridable factory method, separate to allow format-specific mappers (and specifically
XML-backed one, currently) to offer custom |
| protected Object | |
| protected JsonDeserializer | _findRootDeserializer(DeserializationContext ctxt, JavaType valueType)
Method called to locate deserializer for the passed root-level value. |
| protected JsonToken | Returns: First token to be used for data binding after this call: can never be null as exception will be thrown if parser cannot provide more tokens.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 |
| protected ObjectReader | _newReader(DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues)
Factory method sub-classes must override, to produce |
| protected ObjectWriter | _newWriter(SerializationConfig config)
Factory method sub-classes must override, to produce |
| protected ObjectWriter | _newWriter(SerializationConfig config, FormatSchema schema)
Factory method sub-classes must override, to produce |
| protected ObjectWriter | _newWriter(SerializationConfig config, JavaType rootType, PrettyPrinter pp)
Factory method sub-classes must override, to produce |
| protected Object | |
| protected JsonNode | |
| 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
|
| protected final void | |
| protected void | |
| private final void | _writeCloseable(JsonGenerator g, Object value, SerializationConfig cfg)
Helper method used when value to serialize is |
| private final void | _writeCloseableValue(JsonGenerator g, Object value, SerializationConfig cfg)
Helper method used when value to serialize is |
| protected final void | _writeValueAndClose(JsonGenerator g, Object value)
Method called to configure the generator as necessary and then call write functionality |
| public void | acceptJsonFormatVisitor(Class<?>
Type to generate schema for (possibly with generic signature) type, JsonFormatVisitorWrapper visitor)Method for visiting type hierarchy for given type, using specified visitor. |
| public void | acceptJsonFormatVisitor(JavaType
Type to generate schema for (possibly with generic signature) type, JsonFormatVisitorWrapper visitor)Method for visiting type hierarchy for given type, using specified visitor. |
| public ObjectMapper | activateDefaultTyping(PolymorphicTypeValidator
Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized. ptv)Convenience method that is equivalent to calling activateDefaultTyping(ptv, DefaultTyping.OBJECT_AND_NON_CONCRETE); |
| public ObjectMapper | activateDefaultTyping(PolymorphicTypeValidator
Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized. ptv, ObjectMapper.Defines kinds of types for which additional type information
is added; see applicabilityDefaultTyping for more information.Convenience method that is equivalent to calling activateDefaultTyping(ptv, dti, JsonTypeInfo.As.WRAPPER_ARRAY); |
| public ObjectMapper | activateDefaultTyping(PolymorphicTypeValidator
Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized. ptv, ObjectMapper.Defines kinds of types for which additional type information
is added; see applicability,DefaultTyping for more information.Method for enabling automatic inclusion of type information ("Default Typing"),
needed for proper deserialization of polymorphic types (unless types
have been annotated with |
| public ObjectMapper | activateDefaultTypingAsProperty(PolymorphicTypeValidator
Validator used to verify that actual subtypes to deserialize are valid against
whatever criteria validator uses: important in case where untrusted content is deserialized. ptv, ObjectMapper.Defines kinds of types for which additional type information
is added; see applicability,DefaultTyping for more information.Name of property used for including type id for polymorphic values. propertyName)Method for enabling automatic inclusion of type information ("Default Typing")
-- needed for proper deserialization of polymorphic types (unless types
have been annotated with Note choice of |
| public ObjectMapper | addHandler(DeserializationProblemHandler h)
Method for adding specified |
| public ObjectMapper | addMixIn(Class<?>
Class (or interface) whose annotations to effectively override target, Class<?> Class (or interface) whose annotations are to
be "added" to target's annotations, overriding as necessary mixinSource)Method to use for adding mix-in annotations to use for augmenting specified class or interface. |
| public final void | addMixInAnnotations(Class<?> target, Class<?> mixinSource)
Deprecated
Since 2.5: replaced by a fluent form of the method;
addMixIn(Class, Class).
|
| public boolean | Returns: True if mapper can find a serializer for instances of given class (potentially serializable), false otherwise (not serializable)Method that can be called to check whether mapper thinks it could deserialize an Object of given type. |
| public boolean | canDeserialize(JavaType type, AtomicReference<Throwable> cause)
Method similar to |
| public boolean | Returns: True if mapper can find a serializer for instances of given class (potentially serializable), false otherwise (not serializable)Method that can be called to check whether mapper thinks it could serialize an instance of given Class. |
| public boolean | canSerialize(Class<?> type, AtomicReference<Throwable> cause)
Method similar to |
| public ObjectMapper | clearProblemHandlers()
Method for removing all registered |
| public MutableCoercionConfig | coercionConfigDefaults()
Accessor for |
| public MutableCoercionConfig | coercionConfigFor(LogicalType logicalType)
Accessor for |
| public MutableCoercionConfig | coercionConfigFor(Class<?> physicalType)
Accessor for |
| public 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. |
| public ObjectMapper | configure(MapperFeature f, boolean state)
Deprecated
Since 2.13 use
JsonMapper.builder().configure(...)
|
| public ObjectMapper | configure(SerializationFeature f, boolean state)
Method for changing state of an on/off serialization feature for this object mapper. |
| public ObjectMapper | configure(DeserializationFeature f, boolean state)
Method for changing state of an on/off deserialization feature for this object mapper. |
| public ObjectMapper | configure(DatatypeFeature f, boolean state)
Method for changing state of an on/off datatype-specific feature for this object mapper. |
| public ObjectMapper | configure(JsonParser.
Method for changing state of specified |
| public ObjectMapper | configure(JsonGenerator.
Method for changing state of an on/off |
| public JavaType | constructType(Type t)
Convenience method for constructing |
| public JavaType | constructType(TypeReference<?> typeRef)
Convenience method for constructing |
| public <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. |
| public <T> T | |
| public <T> T | |
| public ObjectMapper | copy()
Method for creating a new |
| public ObjectMapper | Returns: ObjectMapperJsonFactory to be used. factory)Method for creating a new |
| public ArrayNode | createArrayNode()
Implements abstract com. 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 |
| public JsonGenerator | createGenerator(OutputStream out)
Factory method for constructing properly initialized |
| public JsonGenerator | createGenerator(OutputStream out, JsonEncoding enc)
Factory method for constructing properly initialized |
| public JsonGenerator | createGenerator(Writer w)
Factory method for constructing properly initialized |
| public JsonGenerator | createGenerator(File outputFile, JsonEncoding enc)
Factory method for constructing properly initialized |
| public JsonGenerator | createGenerator(DataOutput out)
Factory method for constructing properly initialized |
| public JsonParser | createNonBlockingByteArrayParser()
Factory method for constructing properly initialized |
| public ObjectNode | createObjectNode()
Implements abstract com. 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) |
| public JsonParser | createParser(File src)
Factory method for constructing properly initialized |
| public JsonParser | createParser(URL src)
Factory method for constructing properly initialized |
| public JsonParser | createParser(InputStream in)
Factory method for constructing properly initialized |
| public JsonParser | createParser(Reader r)
Factory method for constructing properly initialized |
| public JsonParser | createParser(byte[] content)
Factory method for constructing properly initialized |
| public JsonParser | createParser(byte[] content, int offset, int len)
Factory method for constructing properly initialized |
| public JsonParser | createParser(String content)
Factory method for constructing properly initialized |
| public JsonParser | createParser(char[] content)
Factory method for constructing properly initialized |
| public JsonParser | createParser(char[] content, int offset, int len)
Factory method for constructing properly initialized |
| public JsonParser | createParser(DataInput content)
Factory method for constructing properly initialized |
| public ObjectMapper | deactivateDefaultTyping()
Method for disabling automatic inclusion of type information; if so, only
explicitly annotated types (ones with
|
| protected ClassIntrospector | defaultClassIntrospector()
Overridable helper method used to construct default |
| public ObjectMapper | |
| public ObjectMapper | |
| public ObjectMapper | disable(SerializationFeature first, SerializationFeature... f)
Method for disabling specified |
| public ObjectMapper | disable(DeserializationFeature feature)
Method for disabling specified |
| public ObjectMapper | disable(DeserializationFeature first, DeserializationFeature... f)
Method for disabling specified |
| public ObjectMapper | disable(JsonParser.
Method for disabling specified |
| public ObjectMapper | disable(JsonGenerator.
Method for disabling specified |
| public ObjectMapper | |
| public ObjectMapper | |
| public ObjectMapper | |
| public ObjectMapper | enable(SerializationFeature first, SerializationFeature... f)
Method for enabling specified |
| public ObjectMapper | |
| public ObjectMapper | enable(DeserializationFeature first, DeserializationFeature... f)
Method for enabling specified |
| public ObjectMapper | enable(JsonParser.
Method for enabling specified |
| public ObjectMapper | enable(JsonGenerator.
Method for enabling specified |
| public ObjectMapper | enableDefaultTyping()
Deprecated
Since 2.10 use
activateDefaultTyping(PolymorphicTypeValidator) instead
|
| public ObjectMapper | enableDefaultTyping(ObjectMapper.
Deprecated
Since 2.10 use
activateDefaultTyping(PolymorphicTypeValidator, DefaultTyping) instead
|
| public ObjectMapper | enableDefaultTyping(ObjectMapper.
Deprecated
Since 2.10 use
activateDefaultTyping(PolymorphicTypeValidator, DefaultTyping, JsonTypeInfo. instead
|
| public ObjectMapper | enableDefaultTypingAsProperty(ObjectMapper.
Deprecated
Since 2.10 use
activateDefaultTypingAsProperty(PolymorphicTypeValidator, DefaultTyping, String) instead
|
| public ObjectMapper | findAndRegisterModules()
Convenience method that is functionally equivalent to:
As with |
| public Class | |
| public static List | findModules()
Method for locating available methods, using JDK |
| public static List | findModules(ClassLoader classLoader)
Method for locating available methods, using JDK |
| public JsonSchema | Returns: Constructed JSON schema.The class to generate schema for t)
Deprecated
Since 2.6 use external JSON Schema generator (jackson-module-jsonSchema)
(which under the hood calls
Generate Json-schema
instance for specified class.
acceptJsonFormatVisitor(JavaType, JsonFormatVisitorWrapper))
|
| public DateFormat | |
| public DeserializationConfig | getDeserializationConfig()
Method that returns
the shared default |
| public DeserializationContext | |
| public JsonFactory | getFactory()
Overrides com. JsonFactory) codec will use for data binding.
|
| public InjectableValues | |
| public JsonNodeFactory | getNodeFactory()
Method that can be used to get hold of |
| public PolymorphicTypeValidator | getPolymorphicTypeValidator()
Accessor for configured |
| public PropertyNamingStrategy | |
| public Set | getRegisteredModuleIds()
The set of |
| public SerializationConfig | getSerializationConfig()
Method that returns the shared default |
| public SerializerFactory | |
| public SerializerProvider | getSerializerProvider()
Accessor for the "blueprint" (or, factory) instance, from which instances
are created by calling |
| public SerializerProvider | getSerializerProviderInstance()
Accessor for constructing and returning a |
| public SubtypeResolver | |
| public TypeFactory | |
| public 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. |
| public boolean | |
| public boolean | isEnabled(SerializationFeature f)
Method for checking whether given serialization-specific feature is enabled. |
| public boolean | isEnabled(DeserializationFeature f)
Method for checking whether given deserialization-specific feature is enabled. |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public JsonNode | |
| public int | |
| public JsonNode | |
| public ObjectReader | |
| public ObjectReader | reader(DeserializationFeature feature)
Factory method for constructing |
| public ObjectReader | reader(DeserializationFeature first, DeserializationFeature... other)
Factory method for constructing |
| public ObjectReader | reader(JsonNodeFactory nodeFactory)
Factory method for constructing |
| public ObjectReader | reader(FormatSchema
Schema to pass to parser schema)Factory method for constructing |
| public ObjectReader | reader(InjectableValues
Injectable values to use injectableValues)Factory method for constructing |
| public ObjectReader | reader(Base64Variant defaultBase64)
Factory method for constructing |
| public ObjectReader | reader(ContextAttributes attrs)
Factory method for constructing |
| public ObjectReader | |
| public ObjectReader | |
| public ObjectReader | |
| public ObjectReader | readerFor(JavaType type)
Factory method for constructing |
| public ObjectReader | readerFor(Class<?> type)
Factory method for constructing |
| public ObjectReader | readerFor(TypeReference<?> typeRef)
Factory method for constructing |
| public ObjectReader | readerForArrayOf(Class<?> type)
Factory method for constructing |
| public ObjectReader | readerForListOf(Class<?> type)
Factory method for constructing |
| public ObjectReader | readerForMapOf(Class<?> type)
Factory method for constructing
readerFor(new TypeReference<Map<String, type>>() { });
|
| public ObjectReader | readerForUpdating(Object valueToUpdate)
Factory method for constructing |
| public ObjectReader | readerWithView(Class<?> view)
Factory method for constructing |
| public <T extends TreeNode> T | Returns: aJsonNode, 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()Implements abstract com. JsonNode.
|
| public JsonNode | Returns: aJsonNode, 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()Input stream used to read JSON content
for building the JSON tree. in)Method to deserialize JSON content as tree expressed
using set of |
| public JsonNode | |
| public JsonNode | |
| public JsonNode | readTree(byte[] content)
Same as |
| public JsonNode | readTree(byte[] content, int offset, int len)
Same as |
| public JsonNode | |
| public JsonNode | |
| public <T> T | readValue(JsonParser
Parser to use for decoding content to bind p, Class<T> Java value type to bind content to valueType)Implements abstract com. java.).
|
| public <T> T | readValue(JsonParser
Parser to use for decoding content to bind p, TypeReference<T> Java value type to bind content to valueTypeRef)Implements abstract com. |
| public final <T> T | readValue(JsonParser
Parser to use for decoding content to bind p, ResolvedType Java value type to bind content to valueType)Implements abstract com. |
| public <T> T | readValue(JsonParser p, JavaType valueType)
Type-safe overloaded method, basically alias for |
| public <T> T | |
| public <T> T | readValue(File src, TypeReference<T> valueTypeRef)
Method to deserialize JSON content from given file into given Java type. |
| public <T> T | |
| public <T> T | |
| public <T> T | readValue(URL src, TypeReference<T> valueTypeRef)
Same as |
| public <T> T | readValue(URL src, JavaType valueType)
Same as |
| public <T> T | |
| public <T> T | readValue(String content, TypeReference<T> valueTypeRef)
Method to deserialize JSON content from given JSON content String. |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> T | |
| public <T> MappingIterator | readValues(JsonParser
Parser to use for decoding content to bind p, ResolvedType Java value type to bind content to valueType)Implements abstract com. readerFor(valueType).readValues(p); |
| public <T> MappingIterator | readValues(JsonParser p, JavaType valueType)
Convenience method, equivalent in function to: readerFor(valueType).readValues(p); |
| public <T> MappingIterator | readValues(JsonParser
Parser to use for decoding content to bind p, Class<T> Java value type to bind content to valueType)Implements abstract com. readerFor(valueType).readValues(p); |
| public <T> MappingIterator | readValues(JsonParser
Parser to use for decoding content to bind p, TypeReference<T> Java value type to bind content to valueTypeRef)Implements abstract com. |
| public ObjectMapper | registerModule(Module
Module to register module)Method for registering a module that can extend functionality provided by this mapper; for example, by adding providers for custom serializers and deserializers. |
| public ObjectMapper | registerModules(Module... modules)
Convenience method for registering specified modules in order; functionally equivalent to:
for (Module module : modules) {
registerModule(module);
}
|
| public ObjectMapper | registerModules(Iterable<? extends Module> modules)
Convenience method for registering specified modules in order; functionally equivalent to:
for (Module module : modules) {
registerModule(module);
}
|
| public 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). |
| public 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). |
| public void | |
| private static <T> ServiceLoader | |
| public ObjectMapper | setAccessorNaming(AccessorNamingStrategy.
Method for setting custom accessor naming strategy to use. |
| public ObjectMapper | setAnnotationIntrospector(AnnotationIntrospector ai)
Method for setting |
| public ObjectMapper | setAnnotationIntrospectors(AnnotationIntrospector
AnnotationIntrospector to use for configuring
serializationAnnotationIntrospector to use for configuring
deserializationMethod for changing |
| public ObjectMapper | Returns: This mapper, for convenience to allow chainingBase64 variant to use v)Method that will configure default |
| public ObjectMapper | setCacheProvider(CacheProvider
Cache provider for this mapper to use cacheProvider)Method for specifying |
| public ObjectMapper | setConfig(DeserializationConfig config)
Method that allows overriding of the underlying |
| public ObjectMapper | setConfig(SerializationConfig config)
Method that allows overriding of the underlying |
| public ObjectMapper | setConstructorDetector(ConstructorDetector cd)
Method for specifying |
| public ObjectMapper | setDateFormat(DateFormat dateFormat)
Method for configuring the default |
| public ObjectMapper | setDefaultAttributes(ContextAttributes attrs)
Note preferred way to set the defaults is to use |
| public ObjectMapper | |
| public 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). |
| public ObjectMapper | Returns: This mapper, useful for call-chainingPretty printer to use by default. pp)Method for specifying |
| public ObjectMapper | setDefaultPropertyInclusion(JsonInclude.
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). |
| public ObjectMapper | setDefaultPropertyInclusion(JsonInclude.
Short-cut for: setDefaultPropertyInclusion(JsonInclude.Value.construct(incl, incl)); |
| public ObjectMapper | setDefaultSetterInfo(JsonSetter.
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). |
| public ObjectMapper | setDefaultTyping(TypeResolverBuilder<?>
Type information inclusion handler 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. |
| public ObjectMapper | setDefaultVisibility(JsonAutoDetect.
Method for setting auto-detection visibility definition
defaults, which are in effect unless overridden by
annotations (like |
| public ObjectMapper | setFilterProvider(FilterProvider filterProvider)
Method for configuring this mapper to use specified |
| public void | setFilters(FilterProvider filterProvider)
Deprecated
Since 2.6, use
setFilterProvider instead (allows chaining)
|
| public Object | setHandlerInstantiator(HandlerInstantiator
Instantiator to use; if null, use the default implementation hi)Method for configuring |
| public ObjectMapper | setInjectableValues(InjectableValues injectableValues)
Method for configuring |
| public ObjectMapper | |
| public void | setMixInAnnotations(Map<Class<?>, Class<?>> sourceMixins)
Deprecated
Since 2.5: replaced by a fluent form of the method;
setMixIns.
|
| public ObjectMapper | setMixInResolver(ClassIntrospector.
Method that can be called to specify given resolver for locating mix-in classes to use, overriding directly added mappings. |
| public ObjectMapper | |
| public ObjectMapper | setNodeFactory(JsonNodeFactory f)
Method for specifying |
| public ObjectMapper | setPolymorphicTypeValidator(PolymorphicTypeValidator ptv)
Method for specifying |
| public ObjectMapper | |
| public ObjectMapper | setPropertyNamingStrategy(PropertyNamingStrategy s)
Method for setting custom property naming strategy to use. |
| public ObjectMapper | setSerializationInclusion(JsonInclude.
Convenience method, equivalent to calling: setPropertyInclusion(JsonInclude.Value.construct(incl, incl)); |
| public ObjectMapper | setSerializerFactory(SerializerFactory f)
Method for setting specific |
| public ObjectMapper | setSerializerProvider(DefaultSerializerProvider p)
Method for setting "blueprint" |
| public ObjectMapper | |
| public ObjectMapper | |
| public ObjectMapper | setTypeFactory(TypeFactory f)
Method that can be used to override |
| public ObjectMapper | setVisibility(VisibilityChecker<?> vc)
Method for setting currently configured default |
| public ObjectMapper | Returns: Modified mapper instance (that is, "this"), to allow chaining of configuration callsType of property descriptor affected (field, getter/isGetter,
setter, creator) forMethod, JsonAutoDetect.Minimum visibility to require for the property descriptors of type visibilityConvenience method that allows changing configuration for
underlying |
| public void | setVisibilityChecker(VisibilityChecker<?> vc)
Deprecated
Since 2.6 use
setVisibility(VisibilityChecker) instead.
|
| public JsonFactory | Returns: JsonFactory that this mapper uses when it needs to
construct Json parser and generatorsMethod that can be used to get hold of |
| public JsonParser | treeAsTokens(TreeNode
Root node of the tree that resulting parser will read from n)Implements abstract com. JsonParser out of JSON tree
representation.
|
| public <T> T | treeToValue(TreeNode
Tree to convert n, Class<T> Java target value type to convert content to valueType)Implements abstract com. |
| public <T> T | treeToValue(TreeNode n, JavaType valueType)
Same as |
| public <T> T | treeToValue(TreeNode n, TypeReference<T> toValueTypeRef)
Same as |
| public <T> T | Returns: Either the first argument (`valueToUpdate`), if it is mutable; or a result of creating new instance that is result of "merging" values (for example, "updating" a Java array will create a new array)Object to update valueToUpdate, Object Object to conceptually serialize and merge into value to
update; can be thought of as a provider for overrides to apply. overrides)Convenience method similar to Implementation is approximately as follows:
|
| public < Actual node type; usually either basic T extends JsonNode> TJsonNode or
com. | Returns: (non-null) Root node of the resulting content tree: in case ofnull value node for which JsonNode#isNull() returns true.Java value to convert fromValue)Method that is reverse of |
| public Version | version()
Implements abstract com. Implements com. |
| public ObjectWriter | |
| public ObjectWriter | writer(SerializationFeature feature)
Factory method for constructing |
| public ObjectWriter | writer(SerializationFeature first, SerializationFeature... other)
Factory method for constructing |
| public ObjectWriter | writer(DateFormat df)
Factory method for constructing |
| public ObjectWriter | writer(PrettyPrinter pp)
Factory method for constructing |
| public ObjectWriter | writer(FilterProvider filterProvider)
Factory method for constructing |
| public ObjectWriter | writer(FormatSchema
Schema to pass to generator schema)Factory method for constructing |
| public ObjectWriter | writer(Base64Variant defaultBase64)
Factory method for constructing |
| public ObjectWriter | writer(CharacterEscapes escapes)
Factory method for constructing |
| public ObjectWriter | writer(ContextAttributes attrs)
Factory method for constructing |
| public ObjectWriter | writerFor(Class<?> rootType)
Factory method for constructing |
| public ObjectWriter | writerFor(TypeReference<?> rootType)
Factory method for constructing |
| public ObjectWriter | writerFor(JavaType rootType)
Factory method for constructing |
| public ObjectWriter | writerWithDefaultPrettyPrinter()
Factory method for constructing |
| public ObjectWriter | |
| public ObjectWriter | writerWithType(TypeReference<?> rootType)
Deprecated
Since 2.5, use
writerFor(TypeReference) instead
|
| public ObjectWriter | |
| public ObjectWriter | writerWithView(Class<?> serializationView)
Factory method for constructing |
| public void | writeTree(JsonGenerator
Generator to use for serializing value g, TreeNode Tree to serialize rootNode)Implements abstract com. |
| public void | writeTree(JsonGenerator g, JsonNode rootNode)
Method to serialize given JSON Tree, using generator provided. |
| public void | writeValue(JsonGenerator
Generator to use for serializing value g, Object Value to serialize value)Implements abstract com. JsonGenerator.
|
| public void | writeValue(File resultFile, Object value)
Method that can be used to serialize any Java value as JSON output, written to File provided. |
| public 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
|
| public void | |
| public void | writeValue(Writer w, Object value)
Method that can be used to serialize any Java value as JSON output, using Writer provided. |
| public byte[] | |
| public String |