Package com.fasterxml.jackson.annotation
Enum JsonTypeInfo.As
- java.lang.Object
-
- java.lang.Enum<JsonTypeInfo.As>
-
- com.fasterxml.jackson.annotation.JsonTypeInfo.As
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<JsonTypeInfo.As>
- Enclosing class:
- JsonTypeInfo
public static enum JsonTypeInfo.As extends java.lang.Enum<JsonTypeInfo.As>
Definition of standard type inclusion mechanisms for type metadata. Used for standard metadata types, except forJsonTypeInfo.Id.NONE
. May or may not be used for custom types (JsonTypeInfo.Id.CUSTOM
).
-
-
Enum Constant Summary
Enum Constants Enum Constant Description EXISTING_PROPERTY
Inclusion mechanism similar toPROPERTY
with respect to deserialization; but one that is produced by a "regular" accessible property during serialization.EXTERNAL_PROPERTY
Inclusion mechanism similar toPROPERTY
, except that property is included one-level higher in hierarchy, i.e.PROPERTY
Inclusion mechanism that uses a single configurable property, included along with actual data (POJO properties) as a separate meta-property.WRAPPER_ARRAY
Inclusion mechanism that wraps typed JSON value (POJO serialized as JSON) in a 2-element JSON array: first element is the serialized type identifier, and second element the serialized POJO as JSON Object.WRAPPER_OBJECT
Inclusion mechanism that wraps typed JSON value (POJO serialized as JSON) in a JSON Object that has a single entry, where field name is serialized type identifier, and value is the actual JSON value.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JsonTypeInfo.As
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static JsonTypeInfo.As[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
PROPERTY
public static final JsonTypeInfo.As PROPERTY
Inclusion mechanism that uses a single configurable property, included along with actual data (POJO properties) as a separate meta-property.Default choice for inclusion.
-
WRAPPER_OBJECT
public static final JsonTypeInfo.As WRAPPER_OBJECT
Inclusion mechanism that wraps typed JSON value (POJO serialized as JSON) in a JSON Object that has a single entry, where field name is serialized type identifier, and value is the actual JSON value.Note: can only be used if type information can be serialized as String. This is true for standard type metadata types, but not necessarily for custom types.
-
WRAPPER_ARRAY
public static final JsonTypeInfo.As WRAPPER_ARRAY
Inclusion mechanism that wraps typed JSON value (POJO serialized as JSON) in a 2-element JSON array: first element is the serialized type identifier, and second element the serialized POJO as JSON Object.
-
EXTERNAL_PROPERTY
public static final JsonTypeInfo.As EXTERNAL_PROPERTY
Inclusion mechanism similar toPROPERTY
, except that property is included one-level higher in hierarchy, i.e. as sibling property at same level as JSON Object to type. Note that this mechanism can only be used for properties, not for types (classes). Trying to use it for classes will result in inclusion strategy of basicPROPERTY
instead.Note also that this mechanism can not be used for container values (arrays,
Collection
s,Map
s); it only works for scalar and POJO values.
-
EXISTING_PROPERTY
public static final JsonTypeInfo.As EXISTING_PROPERTY
Inclusion mechanism similar toPROPERTY
with respect to deserialization; but one that is produced by a "regular" accessible property during serialization. This means thatTypeSerializer
will do nothing, and expects a property with defined name to be output using some other mechanism (like default POJO property serialization, or custom serializer).Note that this behavior is quite similar to that of using
JsonTypeId
annotation; except that hereTypeSerializer
is basically suppressed; whereas withJsonTypeId
, output of regular property is suppressed. This mostly matters with respect to output order; this choice is the only way to ensure specific placement of type id during serialization.- Since:
- 2.3.0 but databind only since 2.5.0.
-
-
Method Detail
-
values
public static JsonTypeInfo.As[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JsonTypeInfo.As c : JsonTypeInfo.As.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JsonTypeInfo.As valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
-