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 JacksonModules
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 aJsonMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader).JacksonJsonMessageConverter(MimeType... supportedMimeTypes) Construct a new instance with aJsonMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader)and the providedMimeTypes.JacksonJsonMessageConverter(JsonMapper jsonMapper) Construct a new instance with the providedJsonMapper.JacksonJsonMessageConverter(JsonMapper jsonMapper, MimeType... supportedMimeTypes) Construct a new instance with the providedJsonMapperand the providedMimeTypes. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanConvertFrom(Message<?> message, @Nullable Class<?> targetClass) protected booleancanConvertTo(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.JsonEncodinggetJsonEncoding(@Nullable MimeType contentType) Determine the JSON encoding to use for the given content type.protected JsonMapperReturn the underlyingJsonMapperfor this converter.getSerializationView(@Nullable Object conversionHint) Determine a Jackson serialization view based on the given conversion hint.protected booleanWhether 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 aJsonMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader). -
JacksonJsonMessageConverter
Construct a new instance with aJsonMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader)and the providedMimeTypes.- Parameters:
supportedMimeTypes- the supported MIME types
-
JacksonJsonMessageConverter
Construct a new instance with the providedJsonMapper.- See Also:
-
JacksonJsonMessageConverter
Construct a new instance with the providedJsonMapperand the providedMimeTypes.- See Also:
-
-
Method Details
-
getJsonMapper
Return the underlyingJsonMapperfor this converter. -
canConvertFrom
- Overrides:
canConvertFromin classAbstractMessageConverter
-
canConvertTo
- Overrides:
canConvertToin classAbstractMessageConverter
-
supports
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) 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) 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
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
-
getJsonEncoding
-