public static enum JsonTypeInfo.As extends Enum<JsonTypeInfo.As>
JsonTypeInfo.Id.NONE
.
May or may not be used for custom types (JsonTypeInfo.Id.CUSTOM
).Enum Constant and Description |
---|
EXISTING_PROPERTY
Inclusion mechanism similar to
PROPERTY with respect
to deserialization; but one that is produced by a "regular" accessible
property during serialization. |
EXTERNAL_PROPERTY
Inclusion mechanism similar to
PROPERTY , 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.
|
Modifier and Type | Method and Description |
---|---|
static JsonTypeInfo.As |
valueOf(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.
|
public static final JsonTypeInfo.As PROPERTY
Default choice for inclusion.
public static final JsonTypeInfo.As WRAPPER_OBJECT
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.
public static final JsonTypeInfo.As WRAPPER_ARRAY
public static final JsonTypeInfo.As EXTERNAL_PROPERTY
PROPERTY
, 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 basic PROPERTY
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.
public static final JsonTypeInfo.As EXISTING_PROPERTY
PROPERTY
with respect
to deserialization; but one that is produced by a "regular" accessible
property during serialization. This means that TypeSerializer
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 here TypeSerializer
is basically suppressed;
whereas with JsonTypeId
, 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.
public static JsonTypeInfo.As[] values()
for (JsonTypeInfo.As c : JsonTypeInfo.As.values()) System.out.println(c);
public static JsonTypeInfo.As valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullCopyright © 2021 JBoss by Red Hat. All rights reserved.