Skip to content

Add method ObjectMapper.copyWith(JsonFactory) #3212

Closed
@quaff

Description

@quaff

It's a valid use case that reuse the same configuration over different data formats

ObjectMapper jsonObjectMapper = new ObjectMapper();
// do some configuration ...
ObjectMapper cborObjectMapper = jsonObjectMapper.copyWith(new SmileFactory());

Spring Boot configuration take affect only json format, this will make it possible to all format, for example

 @Bean 
 @ConditionalOnMissingBean(value = MappingJackson2CborHttpMessageConverter.class) 
// other conditions
 MappingJackson2CborHttpMessageConverter mappingJackson2CborHttpMessageConverter(ObjectMapper objectMapper) { 
 	return new MappingJackson2CborHttpMessageConverter(objectMapper.copyWith(new CBORFactory())); 
 } 

spring-projects/spring-boot#27319 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions