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

public abstract class AbstractJsonMessageConverter extends AbstractMessageConverter
Common base class for plain JSON converters, e.g. Gson and JSON-B.
Since:
5.3
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • AbstractJsonMessageConverter

      protected AbstractJsonMessageConverter()
  • Method Details

    • supports

      protected boolean supports(Class<?> clazz)
      Description copied from class: AbstractMessageConverter
      Whether the given class is supported by this converter.
      Specified by:
      supports in class AbstractMessageConverter
      Parameters:
      clazz - the class to test for support
      Returns:
      true if supported; false otherwise
    • convertFromInternal

      @Nullable protected 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 class AbstractMessageConverter
      Parameters:
      message - the input message
      targetClass - the target class for the conversion
      conversionHint - an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}
      Returns:
      the result of the conversion, or null if the converter cannot perform the conversion
    • convertToInternal

      @Nullable protected 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 class AbstractMessageConverter
      Parameters:
      payload - the Object to convert
      headers - optional headers for the message (may be null)
      conversionHint - an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}
      Returns:
      the resulting payload for the message, or null if the converter cannot perform the conversion
    • fromJson

      protected abstract Object fromJson(Reader reader, Type resolvedType)
    • fromJson

      protected abstract Object fromJson(String payload, Type resolvedType)
    • toJson

      protected abstract void toJson(Object payload, Type resolvedType, Writer writer)
    • toJson

      protected abstract String toJson(Object payload, Type resolvedType)