Class JsonSerializer<T>
java.lang.Object
org.springframework.kafka.support.serializer.JsonSerializer<T>
- Type Parameters:
- T- class of the entity, representing messages
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- org.apache.kafka.common.serialization.Serializer<T>
@Deprecated(forRemoval=true,
            since="4.0")
public class JsonSerializer<T>
extends Object
implements org.apache.kafka.common.serialization.Serializer<T>
Deprecated, for removal: This API element is subject to removal in a future version.
Generic 
Serializer for sending
 Java objects to Kafka as JSON.
 
 IMPORTANT: Configuration must be done completely with property setters or via
 configure(Map, boolean), not a mixture. If any setters have been called,
 configure(Map, boolean) will be a no-op.
- Author:
- Igor Stepanov, Artem Bilan, Gary Russell, Elliot Kennedy, Wang Zhiyang, Omer Celik
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.Kafka config property for disabling adding type headers.protected booleanDeprecated, for removal: This API element is subject to removal in a future version.protected final com.fasterxml.jackson.databind.ObjectMapperDeprecated, for removal: This API element is subject to removal in a future version.static final StringDeprecated, for removal: This API element is subject to removal in a future version.Kafka config property to add type mappings to the type mapper: 'foo:com.Foo,bar:com.Bar'.protected Jackson2JavaTypeMapperDeprecated, for removal: This API element is subject to removal in a future version.
- 
Constructor SummaryConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.JsonSerializer(com.fasterxml.jackson.core.type.TypeReference<? super T> targetType) Deprecated, for removal: This API element is subject to removal in a future version.JsonSerializer(com.fasterxml.jackson.core.type.TypeReference<? super T> targetType, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.JsonSerializer(@Nullable com.fasterxml.jackson.databind.JavaType targetType, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.JsonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Deprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.<X> JsonSerializer<X> copyWithType(com.fasterxml.jackson.core.type.TypeReference<? super X> newTargetType) Deprecated, for removal: This API element is subject to removal in a future version.Copies this serializer with same configuration, except new target type reference is used.<X> JsonSerializer<X> copyWithType(com.fasterxml.jackson.databind.JavaType newTargetType) Deprecated, for removal: This API element is subject to removal in a future version.Copies this serializer with same configuration, except new target java type is used.<X> JsonSerializer<X> copyWithType(Class<? super X> newTargetType) Deprecated, for removal: This API element is subject to removal in a future version.Copies this serializer with same configuration, except new target type reference is used.createMappings(String mappings) Deprecated, for removal: This API element is subject to removal in a future version.forKeys()Deprecated, for removal: This API element is subject to removal in a future version.Designate this serializer for serializing keys (default is values); only applies if the default type mapper is used.Deprecated, for removal: This API element is subject to removal in a future version.booleanDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Do not include type info headers.byte[]Deprecated, for removal: This API element is subject to removal in a future version.byte[]Deprecated, for removal: This API element is subject to removal in a future version.voidsetAddTypeInfo(boolean addTypeInfo) Deprecated, for removal: This API element is subject to removal in a future version.Set to false to disable adding type info headers.voidsetTypeMapper(Jackson2JavaTypeMapper typeMapper) Deprecated, for removal: This API element is subject to removal in a future version.Set a customized type mapper.voidsetUseTypeMapperForKey(boolean isKey) Deprecated, for removal: This API element is subject to removal in a future version.Configure the default Jackson2JavaTypeMapper to use key type headers.typeMapper(Jackson2JavaTypeMapper mapper) Deprecated, for removal: This API element is subject to removal in a future version.Use the suppliedJackson2JavaTypeMapper.
- 
Field Details- 
ADD_TYPE_INFO_HEADERSDeprecated, for removal: This API element is subject to removal in a future version.Kafka config property for disabling adding type headers.- See Also:
 
- 
TYPE_MAPPINGSDeprecated, for removal: This API element is subject to removal in a future version.Kafka config property to add type mappings to the type mapper: 'foo:com.Foo,bar:com.Bar'.- See Also:
 
- 
objectMapperprotected final com.fasterxml.jackson.databind.ObjectMapper objectMapperDeprecated, for removal: This API element is subject to removal in a future version.
- 
addTypeInfoprotected boolean addTypeInfoDeprecated, for removal: This API element is subject to removal in a future version.
- 
typeMapperDeprecated, for removal: This API element is subject to removal in a future version.
 
- 
- 
Constructor Details- 
JsonSerializerpublic JsonSerializer()Deprecated, for removal: This API element is subject to removal in a future version.
- 
JsonSerializerDeprecated, for removal: This API element is subject to removal in a future version.
- 
JsonSerializerpublic JsonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.
- 
JsonSerializerpublic JsonSerializer(com.fasterxml.jackson.core.type.TypeReference<? super T> targetType, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.
- 
JsonSerializerpublic JsonSerializer(@Nullable com.fasterxml.jackson.databind.JavaType targetType, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.
 
- 
- 
Method Details- 
isAddTypeInfopublic boolean isAddTypeInfo()Deprecated, for removal: This API element is subject to removal in a future version.
- 
setAddTypeInfopublic void setAddTypeInfo(boolean addTypeInfo) Deprecated, for removal: This API element is subject to removal in a future version.Set to false to disable adding type info headers.- Parameters:
- addTypeInfo- true to add headers.
- Since:
- 2.1
 
- 
getTypeMapperDeprecated, for removal: This API element is subject to removal in a future version.
- 
setTypeMapperDeprecated, for removal: This API element is subject to removal in a future version.Set a customized type mapper.- Parameters:
- typeMapper- the type mapper.
- Since:
- 2.1
 
- 
setUseTypeMapperForKeypublic void setUseTypeMapperForKey(boolean isKey) Deprecated, for removal: This API element is subject to removal in a future version.Configure the default Jackson2JavaTypeMapper to use key type headers.- Parameters:
- isKey- Use key type headers if true
- Since:
- 2.1.3
 
- 
configure
- 
createMappings
- 
serialize
- 
serialize
- 
closepublic void close()Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- org.apache.kafka.common.serialization.Serializer<T>
 
- 
copyWithTypeDeprecated, for removal: This API element is subject to removal in a future version.Copies this serializer with same configuration, except new target type reference is used.- Type Parameters:
- X- new serialization source type
- Parameters:
- newTargetType- type reference forced for serialization, not null
- Returns:
- new instance of serializer with type changes
- Since:
- 2.6
 
- 
copyWithTypepublic <X> JsonSerializer<X> copyWithType(com.fasterxml.jackson.core.type.TypeReference<? super X> newTargetType) Deprecated, for removal: This API element is subject to removal in a future version.Copies this serializer with same configuration, except new target type reference is used.- Type Parameters:
- X- new serialization source type
- Parameters:
- newTargetType- type reference forced for serialization, not null
- Returns:
- new instance of serializer with type changes
- Since:
- 2.6
 
- 
copyWithTypeDeprecated, for removal: This API element is subject to removal in a future version.Copies this serializer with same configuration, except new target java type is used.- Type Parameters:
- X- new serialization source type
- Parameters:
- newTargetType- java type forced for serialization, not null
- Returns:
- new instance of serializer with type changes
- Since:
- 2.6
 
- 
forKeysDeprecated, for removal: This API element is subject to removal in a future version.Designate this serializer for serializing keys (default is values); only applies if the default type mapper is used.- Returns:
- the serializer.
- Since:
- 2.3
- See Also:
 
- 
noTypeInfoDeprecated, for removal: This API element is subject to removal in a future version.Do not include type info headers.- Returns:
- the serializer.
- Since:
- 2.3
- See Also:
 
- 
typeMapperDeprecated, for removal: This API element is subject to removal in a future version.Use the suppliedJackson2JavaTypeMapper.- Parameters:
- mapper- the mapper.
- Returns:
- the serializer.
- Since:
- 2.3
- See Also:
 
 
- 
JacksonJsonSerializerfor Jackson 3.