Class AsDeductionTypeSerializer
java.lang.Object
com.fasterxml.jackson.databind.jsontype.TypeSerializer
com.fasterxml.jackson.databind.jsontype.impl.TypeSerializerBase
com.fasterxml.jackson.databind.jsontype.impl.AsDeductionTypeSerializer
- Since:
- 2.14.2
-
Field Summary
Fields inherited from class TypeSerializerBase
_idResolver, _property -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionforProperty(BeanProperty prop) Method called to create contextual version, to be used for values of given property.com.fasterxml.jackson.annotation.JsonTypeInfo.AsAccessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.static AsDeductionTypeSerializerinstance()com.fasterxml.jackson.core.type.WritableTypeIdwriteTypePrefix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata) Method called to write initial part of type information for given value, along with possible wrapping to use: details are specified by `typeId` argument.com.fasterxml.jackson.core.type.WritableTypeIdwriteTypeSuffix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata) Method that should be called afterTypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)and matching value write have been called, passingWritableTypeIdreturned.Methods inherited from class TypeSerializerBase
_generateTypeId, getPropertyName, getTypeIdResolver, handleMissingId, idFromValue, idFromValueAndTypeMethods inherited from class TypeSerializer
_writeLegacySuffix, typeId, typeId, typeId, writeCustomTypePrefixForArray, writeCustomTypePrefixForObject, writeCustomTypePrefixForScalar, writeCustomTypeSuffixForArray, writeCustomTypeSuffixForObject, writeCustomTypeSuffixForScalar, writeTypePrefixForArray, writeTypePrefixForArray, writeTypePrefixForObject, writeTypePrefixForObject, writeTypePrefixForScalar, writeTypePrefixForScalar, writeTypeSuffixForArray, writeTypeSuffixForObject, writeTypeSuffixForScalar
-
Constructor Details
-
AsDeductionTypeSerializer
protected AsDeductionTypeSerializer()
-
-
Method Details
-
instance
-
forProperty
Description copied from class:TypeSerializerMethod called to create contextual version, to be used for values of given property. This may be the type itself (as is the case for bean properties), or values contained (forCollectionorMapvalued properties).- Specified by:
forPropertyin classTypeSerializer
-
getTypeInclusion
public com.fasterxml.jackson.annotation.JsonTypeInfo.As getTypeInclusion()Description copied from class:TypeSerializerAccessor for type information inclusion method that serializer uses; indicates how type information is embedded in resulting JSON.- Specified by:
getTypeInclusionin classTypeSerializerBase
-
writeTypePrefix
public com.fasterxml.jackson.core.type.WritableTypeId writeTypePrefix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata) throws IOException Description copied from class:TypeSerializerMethod called to write initial part of type information for given value, along with possible wrapping to use: details are specified by `typeId` argument. Note that for structured types (Object, Array), this call will add necessary start token so it should NOT be explicitly written, unlike with non-type-id value writes.See
TypeSerializer.writeTypeSuffix(JsonGenerator, WritableTypeId)for a complete example of typical usage.- Overrides:
writeTypePrefixin classTypeSerializerBase- Parameters:
g- Generator to use for outputting type id and possible wrappingidMetadata- Details of what type id is to be written, how.- Throws:
IOException
-
writeTypeSuffix
public com.fasterxml.jackson.core.type.WritableTypeId writeTypeSuffix(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.type.WritableTypeId idMetadata) throws IOException Description copied from class:TypeSerializerMethod that should be called afterTypeSerializer.writeTypePrefix(JsonGenerator, WritableTypeId)and matching value write have been called, passingWritableTypeIdreturned. Usual idiom is:// Indicator generator that type identifier may be needed; generator may write // one as suggested, modify information, or take some other action // NOTE! For Object/Array types, this will ALSO write start marker! WritableTypeId typeIdDef = typeSer.writeTypePrefix(gen, typeSer.typeId(value, JsonToken.START_OBJECT)); // serializing actual value for which TypeId may have been written... like // NOTE: do NOT write START_OBJECT before OR END_OBJECT after: g.writeStringField("message", "Hello, world!" // matching type suffix call to let generator chance to add suffix, if any // NOTE! For Object/Array types, this will ALSO write end marker! typeSer.writeTypeSuffix(gen, typeIdDef);- Overrides:
writeTypeSuffixin classTypeSerializerBase- Throws:
IOException
-