-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Spring Framework 7.0 introduces Jackson 3 support in parallel of the now deprecated Jackson 2 one.
More information can be found on the changes of migrating from Jackson 2 to Jackson 3 in the following links:
- Taking Jackson 3.0.0-rc1 for a spin
- Jackson 3.0.0-rc2 (minor update)
- Jackson 3.0.0-rc3
- Jackson 3.0.0-rc4
- Path to Jackson 3.0.0
The Jackson 3 changes with the biggest impact on Spring use-cases are:
- Jackson 3 uses a different package (
tools.jackson) than Jackson 2 (com.fasterxml.jackson) except for jackson-annotation (@JsonView,@JsonTypeInfo) which keeps usingcom.fasterxml.jackson ObjectMapper#canDeserializeandObjectMapper#canSerializehave been removed as they were not reliable, so Jackson 3 converters and codecs only test mime types and type resolution in their canXxx methods.- The order of properties is now alphabetical by default (can be changed with
MapperFeature.SORT_PROPERTIES_ALPHABETICALLY) - Slashes are now escaped by default (can be changed with
JsonWriteFeature.ESCAPE_FORWARD_SLASHES, impactProblemDetail) - Jackson 3 defaults are aligned with Spring ones:
MapperFeature.DEFAULT_VIEW_INCLUSIONis disabled by defaultDeserializationFeature.FAIL_ON_UNEXPECTED_VIEW_PROPERTIESis disabled by default
General:
- No Jackson 3 equivalent of
Jackson2ObjectMapperBuilderis provided, the recommendation is to useJsonMapper.builder(),CBORMapper.builder(), etc. - By default, Jackson modules discovered by
MapperBuilder#findModules(java.lang.ClassLoader)are registered in converters and codecs org.springframework.http.converter.json.SpringHandlerInstantiatorenabled by default in Spring MVC ->
org.springframework.http.support.JacksonHandlerInstantiatornow requires explicit configuration- Jackson 3 support is configured if found in the classpath otherwise fallback to Jackson 2
- Jackson 2 support will be deprecated for removal (current plan is autodetection disabled in 7.1, and removal done in 7.2)
WebMVC:
- Switch from
GenericHttpMessageConvertertoSmartHttpMessageConverterwhich support hints - Use hints instead of
MappingJacksonValueandMappingJacksonInputMessageto support@JsonViewandFilterProvider - Introduction of
RequestBodyAdvice#determineReadHintsandResponseBodyAdvice#determineWriteHints JsonViewRequestBodyAdviceandJsonViewResponseBodyAdvicesupports both Jackson 2 (with wrappers) and Jackson 3 (with hints)org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter->org.springframework.http.converter.AbstractJacksonHttpMessageConverterMappingJackson2HttpMessageConverter->JacksonJsonHttpMessageConverterMappingJackson2SmileHttpMessageConverter->JacksonSmileHttpMessageConverterMappingJackson2CborHttpMessageConverter->JacksonCborHttpMessageConverterMappingJackson2XmlHttpMessageConverter->JacksonXmlHttpMessageConverterMappingJackson2YamlHttpMessageConverter->JacksonYamlHttpMessageConverterMappingJackson2JsonView->JacksonJsonViewMappingJackson2XmlView->JacksonXmlView
WebFlux:
org.springframework.http.codec.json.Jackson2CodecSupport->org.springframework.http.codec.JacksonCodecSupportorg.springframework.http.codec.json.Jackson2Tokenizer->org.springframework.http.codec.JacksonTokenizerorg.springframework.http.codec.json.Jackson2SmileDecoder->org.springframework.http.codec.smile.JacksonSmileDecoderorg.springframework.http.codec.json.Jackson2SmileEncoder->org.springframework.http.codec.smile.JacksonSmileEncoderJackson2CborDecoder->JacksonCborDecoderJackson2CborEncoder->JacksonCborEncoderJackson2JsonDecoder->JacksonJsonDecoderJackson2JsonEncoder->JacksonJsonEncoder
Messaging:
MappingJackson2MessageConverter->JacksonJsonMessageConverter
JMS:
MappingJackson2MessageConverter->JacksonJsonMessageConverter
TODO:
- Fix RFC 9457 XML support via
@JacksonXmlRootElementis ignored with Jackson 3 FasterXML/jackson-dataformat-xml#757 - Add support for hints in
RestClientto support@JsonViewandFilterProvider(no support inRestTemplate, migration path will be to switch toRestClient) - Update the reference documentation
vpavic, livk-cloud, anbusampath and nkonev
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement