Class MappingJackson2YamlHttpMessageConverter
- All Implemented Interfaces:
GenericHttpMessageConverter<Object>
,HttpMessageConverter<Object>
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
-
Field Summary
Fields inherited from class org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter
defaultObjectMapper
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger
-
Constructor Summary
ConstructorDescriptionConstruct a newMappingJackson2YamlHttpMessageConverter
using the default configuration provided byJackson2ObjectMapperBuilder
.MappingJackson2YamlHttpMessageConverter
(ObjectMapper objectMapper) Construct a newMappingJackson2YamlHttpMessageConverter
with a customObjectMapper
(must be configured with aYAMLFactory
instance). -
Method Summary
Modifier and TypeMethodDescriptionvoid
setObjectMapper
(ObjectMapper objectMapper) Configure the mainObjectMapper
to use for Object conversion.Methods inherited from class org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter
canRead, canRead, canWrite, customizeReader, customizeWriter, getCharset, getContentLength, getDefaultContentType, getJavaType, getJsonEncoding, getMediaTypesForProblemDetail, getObjectMapper, getObjectMappersForType, getSupportedMediaTypes, logWarningIfNecessary, read, readInternal, registerObjectMappersForType, setPrettyPrint, setSupportedMediaTypes, supportsRepeatableWrites, 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, 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 Details
-
MappingJackson2YamlHttpMessageConverter
public MappingJackson2YamlHttpMessageConverter()Construct a newMappingJackson2YamlHttpMessageConverter
using the default configuration provided byJackson2ObjectMapperBuilder
. -
MappingJackson2YamlHttpMessageConverter
Construct a newMappingJackson2YamlHttpMessageConverter
with a customObjectMapper
(must be configured with aYAMLFactory
instance).You can use
Jackson2ObjectMapperBuilder
to build it easily.- See Also:
-
-
Method Details
-
setObjectMapper
Configure the mainObjectMapper
to use for Object conversion. If not set, a defaultObjectMapper
instance is created.Setting a custom-configured
ObjectMapper
is one way to take further control of the JSON serialization process. For example, an extendedSerializerFactory
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 aYAMLFactory
instance.
-