Search before asking
- [x] I searched in the issues and found nothing similar.
Describe the bug
In 2.20.0, MapperBuilder deprecates the serializationInclusion(JsonInclude.Include)
method in lieu of the defaultPropertyInclusion(JsonInclude.Value)
method.
However, these methods are not compatible with each other, as the former takes JsonInclude.Include
as an argument, while the latter takes JsonInclude.Value
as an argument.
I suspect the intention was to create a defaultPropertyInclusion(JsonInclude.Include)
method (similar to what exists in ObjectMapper) and then deprecate the serializationInclusion(JsonInclude.Include)
for that method instead.
Version Information
2.20.0
Reproduction
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.json.JsonMapper;
public class Foo {
void test() {
var deprecated = JsonMapper.builder().serializationInclusion(JsonInclude.Include.NON_EMPTY).build();
var broken = JsonMapper.builder().defaultPropertyInclusion(JsonInclude.Include.NON_EMPTY).build();
}
}
Expected behavior
No response
Additional context
No response
Comment From: pjfanning
See https://github.com/FasterXML/jackson-databind/discussions/5294
Closing this as we won't be adding the merthod you suggest and so far, the likelihood is that we will add new constants for JsonInclude.Value
Comment From: norrisjeremy
See #5294
Closing this as we won't be adding the merthod you suggest and so far, the likelihood is that we will add new constants for JsonInclude.Value
That is a disappointing outcome.
Comment From: cowtowncoder
Agree with @pjfanning -- in hindsight, adding annotation-constants would have been better experience. But since .0 version is out, additions will need to go in 2.21 anyway.
Note on deprecation: method will remain in 2.x and not removed before 3.0 (from which it was removed a while ago, from 3.0.0-rc1 I think).