public static enum ObjectMapper.DefaultTyping extends Enum<ObjectMapper.DefaultTyping>
ObjectMapper.activateDefaultTyping(PolymorphicTypeValidator)to specify what kind of types (classes) default typing should be used for. It will only be used if no explicit type information is found, but this enumeration further limits subset of those types.
Since 2.4 there are special exceptions for JSON Tree model
types (sub-types of
TreeNode: default typing is never
applied to them.
Since 2.8(.4) additional checks are made to avoid attempts at default
typing primitive-valued properties.
NOTE: use of Default Typing can be a potential security risk if incoming
content comes from untrusted sources, and it is recommended that this
is either not done, or, if enabled, make sure to
methods that take
PolymorphicTypeValidator that limits applicability
to known trusted types.
|Enum Constant and Description|
Value that means that default typing will be used for all types, with exception of small number of "natural" types (String, Boolean, Integer, Double) that can be correctly inferred from JSON, and primitives (which can not be polymorphic either).
This value means that only properties that have
Value that means that default typing will be used for all types covered by
Value that means that default typing will be used for all non-final types, with exception of small number of "natural" types (String, Boolean, Integer, Double), which can be correctly inferred from JSON; as well as for all arrays of non-final types.
Value that means that default typing will be used for properties with declared type of
|Modifier and Type||Method and Description|
Returns the enum constant of this type with the specified name.
Returns an array containing the constants of this enum type, in the order they are declared.
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
public static final ObjectMapper.DefaultTyping JAVA_LANG_OBJECT
Objectas declared type (including generic types without explicit type) will use default typing.
public static final ObjectMapper.DefaultTyping OBJECT_AND_NON_CONCRETE
public static final ObjectMapper.DefaultTyping NON_CONCRETE_AND_ARRAYS
public static final ObjectMapper.DefaultTyping NON_FINAL
Since 2.4, this does NOT apply to
TreeNode and its subtypes.
public static final ObjectMapper.DefaultTyping EVERYTHING
WARNING: most of the time this is NOT the setting you want
as it tends to add Type Ids everywhere, even in cases
where type can not be anything other than declared (for example
if declared value type of a property is
final -- for example,
properties of type
long (or wrapper
Note that this is rarely the option you should use as it results in adding type information in many places where it should not be needed: make sure you understand its behavior. The only known use case for this setting is for serialization when passing instances of final class, and base type is not separately specified.
public static ObjectMapper.DefaultTyping values()
for (ObjectMapper.DefaultTyping c : ObjectMapper.DefaultTyping.values()) System.out.println(c);
public static ObjectMapper.DefaultTyping valueOf(String name)
Copyright © 2008–2020 FasterXML. All rights reserved.