Open chonton opened 2 years ago
/cc @geoand, @gsmet
For outward compatibility producing a JsonMapper
will fulfill injection requirements for ObjectMapper
.
This will require changing the default ObjectMapper producer and change the interface of ObjectMapperCustomizer. What backward compatibility is required?
This is a pretty severe breaking change that could affect a lot of people. I am not sure I want to do that just yet.
https://github.com/quarkusio/quarkus/issues/23645 is also related
This will require changing the default ObjectMapper producer and change the interface of ObjectMapperCustomizer. What backward compatibility is required?
This is a pretty severe breaking change that could affect a lot of people. I am not sure I want to do that just yet.
What about in Quarkus 3.0?
Perhaps
An additional complexity here is that there are two "layers" of customization in Jackson: the main one is the mapper itself (through some MapperBuilder
), but the mapper builder itself can also be instantiated with a factory (used by the eventual mapper to create things at runtime), and this factory also has a builder interface. It is very convoluted, unfortunately, but the workflow is roughly as follows:
val factoryBuilder = JsonFactoryBuilder(JsonFactory())
// apply customizations on the factoryBuilder
val factory = factoryBuilder.build()
val mapperBuilder = JsonMapper.builder(factory)
// apply customizations for the mapperBuilder
val mapper = mapperBuilder.build()
Luckily, both these levels can be made more generic using the backing interfaces TSFBuilder
and MapperBuilder
, so it is possible to implement generic customizations that are applicable to any implementation of these builders - so all Quarkus customizations will be applied to all mappers (not just JSON, but also YAML/CSV/etc)
At my own work, I implemented a version of this that exposes a generic customizer interface that can be used on all levels: either all <factory/mapper> builders, or only the builders specific to a type such as JSON/YAML/CSV. For reference: https://gitlab.com/rug-digitallab/resources/common-quarkus/-/merge_requests/33/diffs. This implementation is currently fully backwards-compatible with the existing customizers.
I would be happy to port this approach to Quarkus at some point when you deem this relevant.
That seems interesting @FWest98!
Would you like to open a draft PR showing what you have in mind?
Description
As of 2.10, JsonMapper appears to be the preferred system.
This will require changing the default ObjectMapper producer and change the interface of ObjectMapperCustomizer.
What backward compatibility is required?
Implementation ideas