Class JacksonJsonMessageConverter
java.lang.Object
org.springframework.messaging.converter.AbstractMessageConverter
org.springframework.messaging.converter.JacksonJsonMessageConverter
- All Implemented Interfaces:
MessageConverter
,SmartMessageConverter
A Jackson 3.x based
MessageConverter
implementation.
The default constructor loads JacksonModule
s
found by MapperBuilder.findModules(ClassLoader)
.
- Since:
- 7.0
- Author:
- Sebastien Deleuze
-
Field Summary
Fields inherited from class org.springframework.messaging.converter.AbstractMessageConverter
logger
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance with aJsonMapper
customized with theJacksonModule
s found byMapperBuilder.findModules(ClassLoader)
.JacksonJsonMessageConverter
(MimeType... supportedMimeTypes) Construct a new instance with aJsonMapper
customized with theJacksonModule
s found byMapperBuilder.findModules(ClassLoader)
and the providedMimeType
s.JacksonJsonMessageConverter
(ObjectMapper objectMapper) Construct a new instance with the providedObjectMapper
.JacksonJsonMessageConverter
(ObjectMapper objectMapper, MimeType... supportedMimeTypes) Construct a new instance with the providedObjectMapper
and the providedMimeType
s. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
canConvertFrom
(Message<?> message, @Nullable Class<?> targetClass) protected boolean
canConvertTo
(Object payload, @Nullable MessageHeaders headers) convertFromInternal
(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) Convert the message payload from serialized form to an Object.convertToInternal
(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) Convert the payload object to serialized form.protected tools.jackson.core.JsonEncoding
getJsonEncoding
(@Nullable MimeType contentType) Determine the JSON encoding to use for the given content type.getSerializationView
(@Nullable Object conversionHint) Determine a Jackson serialization view based on the given conversion hint.protected boolean
Whether the given class is supported by this converter.Methods inherited from class org.springframework.messaging.converter.AbstractMessageConverter
addSupportedMimeTypes, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
-
Constructor Details
-
JacksonJsonMessageConverter
public JacksonJsonMessageConverter()Construct a new instance with aJsonMapper
customized with theJacksonModule
s found byMapperBuilder.findModules(ClassLoader)
. -
JacksonJsonMessageConverter
Construct a new instance with aJsonMapper
customized with theJacksonModule
s found byMapperBuilder.findModules(ClassLoader)
and the providedMimeType
s.- Parameters:
supportedMimeTypes
- the supported MIME types
-
JacksonJsonMessageConverter
Construct a new instance with the providedObjectMapper
.- See Also:
-
JacksonJsonMessageConverter
Construct a new instance with the providedObjectMapper
and the providedMimeType
s.- See Also:
-
-
Method Details
-
canConvertFrom
- Overrides:
canConvertFrom
in classAbstractMessageConverter
-
canConvertTo
- Overrides:
canConvertTo
in classAbstractMessageConverter
-
supports
Description copied from class:AbstractMessageConverter
Whether the given class is supported by this converter.- Specified by:
supports
in classAbstractMessageConverter
- Parameters:
clazz
- the class to test for support- Returns:
true
if supported;false
otherwise
-
convertFromInternal
protected @Nullable Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) Description copied from class:AbstractMessageConverter
Convert the message payload from serialized form to an Object.- Overrides:
convertFromInternal
in 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
null
if the converter cannot perform the conversion
-
convertToInternal
protected @Nullable Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) Description copied from class:AbstractMessageConverter
Convert the payload object to serialized form.- Overrides:
convertToInternal
in 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
null
if the converter cannot perform the conversion
-
getSerializationView
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
null
if none
-
getJsonEncoding
-