Class MappingJackson2YamlHttpMessageConverter

All Implemented Interfaces:
GenericHttpMessageConverter<Object>, HttpMessageConverter<Object>

public class MappingJackson2YamlHttpMessageConverter extends AbstractJackson2HttpMessageConverter
Implementation of HttpMessageConverter that can read and write the YAML data format using the dedicated Jackson 2.x extension.

By default, this converter supports the MediaType.APPLICATION_YAML_VALUE media type. This can be overridden by setting the supportedMediaTypes property.

The default constructor uses the default configuration provided by Jackson2ObjectMapperBuilder.

Since:
6.2
Author:
Hyoungjune Kim
  • Constructor Details

    • MappingJackson2YamlHttpMessageConverter

      public MappingJackson2YamlHttpMessageConverter()
      Construct a new MappingJackson2YamlHttpMessageConverter using the default configuration provided by Jackson2ObjectMapperBuilder.
    • MappingJackson2YamlHttpMessageConverter

      public MappingJackson2YamlHttpMessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Construct a new MappingJackson2YamlHttpMessageConverter with a custom ObjectMapper (must be configured with a YAMLFactory instance).

      You can use Jackson2ObjectMapperBuilder to build it easily.

      See Also:
  • Method Details

    • setObjectMapper

      public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Configure the main ObjectMapper to use for Object conversion. If not set, a default ObjectMapper instance is created.

      Setting a custom-configured ObjectMapper is one way to take further control of the JSON serialization process. For example, an extended SerializerFactory can be configured that provides custom serializers for specific types. Another option for refining the serialization process is to use Jackson's provided annotations on the types to be serialized, in which case a custom-configured ObjectMapper is unnecessary.

      The ObjectMapper must be configured with a YAMLFactory instance.

      Overrides:
      setObjectMapper in class AbstractJackson2HttpMessageConverter
      See Also: