Jackson Glossary: JsonTypeInfo
- Type: Annotation
Package: com.fasterxml.jackson.annotation (2.x), org.codehaus.jackson (1.x)
Jar: jackson-core
Role
This is the main annotation used to enable handling of polymorphic types: that is, cases where actual type of a property value may be one of multiple subtypes, and the declared (static) type is not enough to determine which one to deserialize value as.
Properties
use: defines what kind of Type Identifier is to be used: either a logical type name (separately defined), or Java class name
include: (optional) how is the Type Identifier going to be included? As a sibling property of data; as a wrapper array or obejct; or as an "external" property?
defaultImpl: (optional) If Type Identifier is missing (or is invalid), can deserializer use a default fallback class? If so, this property defines that class
(since 2.0) visible: (optional, default: false) Whether Type Identifier should be exposed during deserialization or not: if it is, it will be seen as part of token stream exposed via JsonParser; and if result POJO has a matching property, property will be set to that id.
Usage
This annotation is added either to a Class (which MUST be the base class of subtypes that are used); or to a property. Interpretation differs in that when used for a property, information will apply to contents of container types (Lists, Maps, arrays).
Back to Jackson Term Glossary
