Class Jackson2CodecSupport
java.lang.Object
org.springframework.http.codec.json.Jackson2CodecSupport
- Direct Known Subclasses:
AbstractJackson2Decoder
,AbstractJackson2Encoder
Deprecated, for removal: This API element is subject to removal in a future version.
Base class providing support methods for Jackson 2.x encoding and decoding.
- Since:
- 5.0
- Author:
- Sebastien Deleuze, Rossen Stoyanchev
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Deprecated, for removal: This API element is subject to removal in a future version.The key for the hint to specify a "JSON View" for encoding or decoding with the value expected to be aClass
.protected final org.apache.commons.logging.Log
Deprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Jackson2CodecSupport
(com.fasterxml.jackson.databind.ObjectMapper objectMapper, MimeType... mimeTypes) Deprecated, for removal: This API element is subject to removal in a future version.Constructor with a JacksonObjectMapper
to use. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract <A extends Annotation>
@Nullable AgetAnnotation
(MethodParameter parameter, Class<A> annotType) Deprecated, for removal: This API element is subject to removal in a future version.getHints
(ResolvableType resolvableType) Deprecated, for removal: This API element is subject to removal in a future version.protected com.fasterxml.jackson.databind.JavaType
getJavaType
(Type type, @Nullable Class<?> contextClass) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Return the supported media type(s) forProblemDetail
.Deprecated, for removal: This API element is subject to removal in a future version.Subclasses should expose this as "decodable" or "encodable" mime types.getMimeTypes
(ResolvableType elementType) Deprecated, for removal: This API element is subject to removal in a future version.com.fasterxml.jackson.databind.ObjectMapper
Deprecated, for removal: This API element is subject to removal in a future version.Return theconfigured
default ObjectMapper.Deprecated, for removal: This API element is subject to removal in a future version.getObjectMappersForType
(Class<?> clazz) Deprecated, for removal: This API element is subject to removal in a future version.Return ObjectMapper registrations for the given class, if any.protected @Nullable MethodParameter
getParameter
(ResolvableType type) Deprecated, for removal: This API element is subject to removal in a future version.protected void
logWarningIfNecessary
(Type type, @Nullable Throwable cause) Deprecated, for removal: This API element is subject to removal in a future version.Determine whether to log the given exception coming from aObjectMapper.canDeserialize(com.fasterxml.jackson.databind.JavaType)
/ObjectMapper.canSerialize(java.lang.Class<?>)
check.void
registerObjectMappersForType
(Class<?> clazz, Consumer<Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper>> registrar) Deprecated, for removal: This API element is subject to removal in a future version.Configure theObjectMapper
instances to use for the givenClass
.protected @Nullable com.fasterxml.jackson.databind.ObjectMapper
selectObjectMapper
(ResolvableType targetType, @Nullable MimeType targetMimeType) Deprecated, for removal: This API element is subject to removal in a future version.Select an ObjectMapper to use, either the main ObjectMapper or another if the handling for the given Class has been customized throughregisterObjectMappersForType(Class, Consumer)
.void
setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.Configure the default ObjectMapper instance to use.protected boolean
supportsMimeType
(@Nullable MimeType mimeType) Deprecated, for removal: This API element is subject to removal in a future version.
-
Field Details
-
JSON_VIEW_HINT
-
logger
protected final org.apache.commons.logging.Log loggerDeprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
Jackson2CodecSupport
protected Jackson2CodecSupport(com.fasterxml.jackson.databind.ObjectMapper objectMapper, MimeType... mimeTypes) Deprecated, for removal: This API element is subject to removal in a future version.Constructor with a JacksonObjectMapper
to use.
-
-
Method Details
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Deprecated, for removal: This API element is subject to removal in a future version.Configure the default ObjectMapper instance to use.- Parameters:
objectMapper
- the ObjectMapper instance- Since:
- 5.3.4
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Deprecated, for removal: This API element is subject to removal in a future version.Return theconfigured
default ObjectMapper. -
registerObjectMappersForType
public void registerObjectMappersForType(Class<?> clazz, Consumer<Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper>> registrar) Deprecated, for removal: This API element is subject to removal in a future version.Configure theObjectMapper
instances to use for the givenClass
. This is useful when you want to deviate from thedefault
ObjectMapper or have theObjectMapper
vary byMediaType
.Note: Use of this method effectively turns off use of the default
ObjectMapper
and supportedMimeTypes
for the given class. Therefore it is important for the mappings configured here toinclude
every MediaType that must be supported for the given class.- Parameters:
clazz
- the type of Object to register ObjectMapper instances forregistrar
- a consumer to populate or otherwise update the MediaType-to-ObjectMapper associations for the given Class- Since:
- 5.3.4
-
getObjectMappersForType
public @Nullable Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper> getObjectMappersForType(Class<?> clazz) Deprecated, for removal: This API element is subject to removal in a future version.Return ObjectMapper registrations for the given class, if any.- Parameters:
clazz
- the class to look up for registrations for- Returns:
- a map with registered MediaType-to-ObjectMapper registrations, or empty if in case of no registrations for the given class.
- Since:
- 5.3.4
-
getObjectMapperRegistrations
-
getMimeTypes
-
getMimeTypes
Deprecated, for removal: This API element is subject to removal in a future version. -
getMediaTypesForProblemDetail
Deprecated, for removal: This API element is subject to removal in a future version.Return the supported media type(s) forProblemDetail
. By default, an empty list, unless overridden in subclasses.- Since:
- 6.0.5
-
supportsMimeType
-
logWarningIfNecessary
Deprecated, for removal: This API element is subject to removal in a future version.Determine whether to log the given exception coming from aObjectMapper.canDeserialize(com.fasterxml.jackson.databind.JavaType)
/ObjectMapper.canSerialize(java.lang.Class<?>)
check.- Parameters:
type
- the class that Jackson tested for (de-)serializabilitycause
- the Jackson-thrown exception to evaluate (typically aJsonMappingException
)- Since:
- 5.3.1
-
getJavaType
-
getHints
Deprecated, for removal: This API element is subject to removal in a future version. -
getParameter
Deprecated, for removal: This API element is subject to removal in a future version. -
getAnnotation
protected abstract <A extends Annotation> @Nullable A getAnnotation(MethodParameter parameter, Class<A> annotType) Deprecated, for removal: This API element is subject to removal in a future version. -
selectObjectMapper
protected @Nullable com.fasterxml.jackson.databind.ObjectMapper selectObjectMapper(ResolvableType targetType, @Nullable MimeType targetMimeType) Deprecated, for removal: This API element is subject to removal in a future version.Select an ObjectMapper to use, either the main ObjectMapper or another if the handling for the given Class has been customized throughregisterObjectMappersForType(Class, Consumer)
.- Since:
- 5.3.4
-
JacksonCodecSupport