org.springframework.http.converter.cbor

## Class MappingJackson2CborHttpMessageConverter

- java.lang.Object
- - org.springframework.http.converter.AbstractHttpMessageConverter<T>
  - - org.springframework.http.converter.AbstractGenericHttpMessageConverter<Object>
    - - org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter
      - - org.springframework.http.converter.cbor.MappingJackson2CborHttpMessageConverter

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

      public class MappingJackson2CborHttpMessageConverter
      extends AbstractJackson2HttpMessageConverter

  Implementation of `HttpMessageConverter` that can read and write the CBOR data format using the dedicated Jackson 2.x extension.

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

  The default constructor uses the default configuration provided by `Jackson2ObjectMapperBuilder`.

  Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.

  Since:
    5.0
  Author:
    Sebastien Deleuze

- - ### Field Summary

    - ### Fields inherited from class org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter

      `DEFAULT_CHARSET, defaultObjectMapper`

    - ### Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MappingJackson2CborHttpMessageConverter()` Construct a new `MappingJackson2CborHttpMessageConverter` using the default configuration provided by `Jackson2ObjectMapperBuilder`.
    `MappingJackson2CborHttpMessageConverter(ObjectMapper objectMapper)` Construct a new `MappingJackson2CborHttpMessageConverter` with a custom `ObjectMapper` (must be configured with a `CBORFactory` instance).

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `setObjectMapper(ObjectMapper objectMapper)` Configure the main `ObjectMapper` to use for Object conversion.

    - ### Methods inherited from class org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter

      `canRead, canRead, canWrite, getCharset, getContentLength, getDefaultContentType, getJavaType, getJsonEncoding, getObjectMapper, getObjectMappersForType, getSupportedMediaTypes, logWarningIfNecessary, read, readInternal, registerObjectMappersForType, setPrettyPrint, writeInternal, writePrefix, writeSuffix`

    - ### Methods inherited from class org.springframework.http.converter.AbstractGenericHttpMessageConverter

      `canWrite, supports, write, writeInternal`

    - ### Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

      `addDefaultHeaders, canRead, canWrite, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.http.converter.HttpMessageConverter

      `getSupportedMediaTypes, read, write`

- - ### Constructor Detail

    - #### MappingJackson2CborHttpMessageConverter

          public MappingJackson2CborHttpMessageConverter()

      Construct a new `MappingJackson2CborHttpMessageConverter` using the default configuration provided by `Jackson2ObjectMapperBuilder`.

    - #### MappingJackson2CborHttpMessageConverter

          public MappingJackson2CborHttpMessageConverter(ObjectMapper objectMapper)

      Construct a new `MappingJackson2CborHttpMessageConverter` with a custom `ObjectMapper` (must be configured with a `CBORFactory` instance).

      You can use `Jackson2ObjectMapperBuilder` to build it easily.

      See Also:
        `Jackson2ObjectMapperBuilder.cbor()`

  - ### Method Detail

    - #### setObjectMapper

          public void setObjectMapper(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 `CBORFactory` instance.

      Overrides:
        `setObjectMapper` in class `AbstractJackson2HttpMessageConverter`
      See Also:
        `AbstractJackson2HttpMessageConverter.registerObjectMappersForType(Class, Consumer)`