Class MappingJackson2MessageConverter
java.lang.Object
org.springframework.messaging.converter.AbstractMessageConverter
org.springframework.messaging.converter.MappingJackson2MessageConverter
- All Implemented Interfaces:
MessageConverter, SmartMessageConverter
@Deprecated(since="7.0",
forRemoval=true)
public class MappingJackson2MessageConverter
extends AbstractMessageConverter
Deprecated, for removal: This API element is subject to removal in a future version.
A Jackson 2 based
MessageConverter implementation.
It customizes Jackson's default properties with the following ones:
MapperFeature.DEFAULT_VIEW_INCLUSIONis disabledDeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIESis disabled
- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze
-
Field Summary
Fields inherited from class AbstractMessageConverter
logger -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a defaultObjectMapper, supporting theapplication/jsonMIME type withUTF-8character set.MappingJackson2MessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a customObjectMapper, supporting theapplication/jsonMIME type withUTF-8character set.MappingJackson2MessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper, MimeType... supportedMimeTypes) Deprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a customObjectMapper, supporting one or more custom MIME types.MappingJackson2MessageConverter(MimeType... supportedMimeTypes) Deprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a defaultObjectMapper, supporting one or more custom MIME types. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanConvertFrom(Message<?> message, @Nullable Class<?> targetClass) Deprecated, for removal: This API element is subject to removal in a future version.protected booleancanConvertTo(Object payload, @Nullable MessageHeaders headers) Deprecated, for removal: This API element is subject to removal in a future version.convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) Deprecated, for removal: This API element is subject to removal in a future version.Convert the message payload from serialized form to an Object.convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) Deprecated, for removal: This API element is subject to removal in a future version.Convert the payload object to serialized form.protected com.fasterxml.jackson.core.JsonEncodinggetJsonEncoding(@Nullable MimeType contentType) Deprecated, for removal: This API element is subject to removal in a future version.Determine the JSON encoding to use for the given content type.com.fasterxml.jackson.databind.ObjectMapperDeprecated, for removal: This API element is subject to removal in a future version.Return the underlyingObjectMapperfor this converter.getSerializationView(@Nullable Object conversionHint) Deprecated, for removal: This API element is subject to removal in a future version.Determine a Jackson serialization view based on the given conversion hint.protected voidlogWarningIfNecessary(Type type, @Nullable Throwable cause) Deprecated, for removal: This API element is subject to removal in a future version.Determine whether to log the given exception coming from aObjectMapper.canDeserialize(JavaType)/ObjectMapper.canSerialize(Class)check.voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.Set theObjectMapperfor this converter.voidsetPrettyPrint(boolean prettyPrint) Deprecated, for removal: This API element is subject to removal in a future version.Whether to use theDefaultPrettyPrinterwhen writing JSON.protected booleanDeprecated, for removal: This API element is subject to removal in a future version.Whether the given class is supported by this converter.Methods inherited from class AbstractMessageConverter
addSupportedMimeTypes, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
-
Constructor Details
-
MappingJackson2MessageConverter
public MappingJackson2MessageConverter()Deprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a defaultObjectMapper, supporting theapplication/jsonMIME type withUTF-8character set. -
MappingJackson2MessageConverter
Deprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a defaultObjectMapper, supporting one or more custom MIME types.- Parameters:
supportedMimeTypes- the supported MIME types- Since:
- 4.1.5
-
MappingJackson2MessageConverter
public MappingJackson2MessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a customObjectMapper, supporting theapplication/jsonMIME type withUTF-8character set.- Parameters:
objectMapper- theObjectMapperto use- Since:
- 6.1
-
MappingJackson2MessageConverter
public MappingJackson2MessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper, MimeType... supportedMimeTypes) Deprecated, for removal: This API element is subject to removal in a future version.Construct aMappingJackson2MessageConverterwith a customObjectMapper, supporting one or more custom MIME types.- Parameters:
objectMapper- theObjectMapperto usesupportedMimeTypes- the supported MIME types- Since:
- 6.1
-
-
Method Details
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.Set theObjectMapperfor this converter.If not set, a default
ObjectMapperis used.Setting a custom-configured
ObjectMapperis one way to take further control of the JSON serialization process. For example, an extendedSerializerFactorycan be configured that provides custom serializers for specific types. The other option for refining the serialization process is to use Jackson's provided annotations on the types to be serialized, in which case a custom-configuredObjectMapperis unnecessary. -
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Deprecated, for removal: This API element is subject to removal in a future version.Return the underlyingObjectMapperfor this converter. -
setPrettyPrint
public void setPrettyPrint(boolean prettyPrint) Deprecated, for removal: This API element is subject to removal in a future version.Whether to use theDefaultPrettyPrinterwhen writing JSON.This is a shortcut for setting up an
ObjectMapperas follows:ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); converter.setObjectMapper(mapper);
-
canConvertFrom
Deprecated, for removal: This API element is subject to removal in a future version.- Overrides:
canConvertFromin classAbstractMessageConverter
-
canConvertTo
Deprecated, for removal: This API element is subject to removal in a future version.- Overrides:
canConvertToin classAbstractMessageConverter
-
logWarningIfNecessary
Deprecated, for removal: This API element is subject to removal in a future version.Determine whether to log the given exception coming from aObjectMapper.canDeserialize(JavaType)/ObjectMapper.canSerialize(Class)check.- Parameters:
type- the class that Jackson tested for (de-)serializabilitycause- the Jackson-thrown exception to evaluate (typically aJsonMappingException)- Since:
- 4.3
-
supports
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from class:AbstractMessageConverterWhether the given class is supported by this converter.- Specified by:
supportsin classAbstractMessageConverter- Parameters:
clazz- the class to test for support- Returns:
trueif supported;falseotherwise
-
convertFromInternal
protected @Nullable Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from class:AbstractMessageConverterConvert the message payload from serialized form to an Object.- Overrides:
convertFromInternalin classAbstractMessageConverter- Parameters:
message- the input messagetargetClass- the target class for the conversionconversionHint- an extra object passed to theMessageConverter, for example, the associatedMethodParameter(may benull)- Returns:
- the result of the conversion, or
nullif the converter cannot perform the conversion
-
convertToInternal
protected @Nullable Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from class:AbstractMessageConverterConvert the payload object to serialized form.- Overrides:
convertToInternalin classAbstractMessageConverter- Parameters:
payload- the Object to convertheaders- optional headers for the message (may benull)conversionHint- an extra object passed to theMessageConverter, for example, the associatedMethodParameter(may benull)- Returns:
- the resulting payload for the message, or
nullif the converter cannot perform the conversion
-
getSerializationView
Deprecated, for removal: This API element is subject to removal in a future version.Determine a Jackson serialization view based on the given conversion hint.- Parameters:
conversionHint- the conversion hint Object as passed into the converter for the current conversion attempt- Returns:
- the serialization view class, or
nullif none - Since:
- 4.2
-
getJsonEncoding
Deprecated, for removal: This API element is subject to removal in a future version.Determine the JSON encoding to use for the given content type.- Parameters:
contentType- the MIME type from the MessageHeaders, if any- Returns:
- the JSON encoding to use (never
null)
-
JacksonJsonMessageConverter