Class AbstractJsonMessageConverter
java.lang.Object
org.springframework.messaging.converter.AbstractMessageConverter
org.springframework.messaging.converter.AbstractJsonMessageConverter
- All Implemented Interfaces:
MessageConverter
,SmartMessageConverter
- Direct Known Subclasses:
GsonMessageConverter
,JsonbMessageConverter
,KotlinSerializationJsonMessageConverter
Common base class for plain JSON converters, for example, Gson and JSON-B.
- Since:
- 5.3
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.messaging.converter.AbstractMessageConverter
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvertFromInternal
(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 abstract Object
protected abstract Object
protected boolean
Whether the given class is supported by this converter.protected abstract String
protected abstract void
Methods inherited from class org.springframework.messaging.converter.AbstractMessageConverter
addSupportedMimeTypes, canConvertFrom, canConvertTo, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
-
Constructor Details
-
AbstractJsonMessageConverter
protected AbstractJsonMessageConverter()
-
-
Method Details
-
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
-
fromJson
- Throws:
IOException
-
fromJson
-
toJson
- Throws:
IOException
-
toJson
-