public class MappingJackson2SmileHttpMessageConverter extends AbstractJackson2HttpMessageConverter
HttpMessageConverter
that can read and write Smile data format ("binary JSON") using
the dedicated Jackson 2.x extension.
By default, this converter supports "application/x-jackson-smile"
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.
DEFAULT_CHARSET, defaultObjectMapper
logger
Constructor and Description |
---|
MappingJackson2SmileHttpMessageConverter()
Construct a new
MappingJackson2SmileHttpMessageConverter using default configuration
provided by Jackson2ObjectMapperBuilder . |
MappingJackson2SmileHttpMessageConverter(ObjectMapper objectMapper)
Construct a new
MappingJackson2SmileHttpMessageConverter with a custom ObjectMapper
(must be configured with a SmileFactory instance). |
Modifier and Type | Method and Description |
---|---|
void |
setObjectMapper(ObjectMapper objectMapper)
Configure the main
ObjectMapper to use for Object conversion. |
canRead, canRead, canWrite, getCharset, getContentLength, getDefaultContentType, getJavaType, getJsonEncoding, getObjectMapper, getObjectMappersForType, getSupportedMediaTypes, logWarningIfNecessary, read, readInternal, registerObjectMappersForType, setPrettyPrint, writeInternal, writePrefix, writeSuffix
canWrite, supports, write, writeInternal
addDefaultHeaders, canRead, canWrite, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSupportedMediaTypes, read, write
public MappingJackson2SmileHttpMessageConverter()
MappingJackson2SmileHttpMessageConverter
using default configuration
provided by Jackson2ObjectMapperBuilder
.public MappingJackson2SmileHttpMessageConverter(ObjectMapper objectMapper)
MappingJackson2SmileHttpMessageConverter
with a custom ObjectMapper
(must be configured with a SmileFactory
instance).
You can use Jackson2ObjectMapperBuilder
to build it easily.Jackson2ObjectMapperBuilder.smile()
public void setObjectMapper(ObjectMapper objectMapper)
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 SmileFactory
instance.