I have a problem with setting a deserialization feature in Jackson 3. With Jackson 3 there's a change in behavior while mapping null values into primitive types. I created a configuration class, but unfortunately it's not working and I still get error while deserialization. What am I missing?
@Configuration
public class JsonMapperConfig {
@Bean
@Primary
JsonMapperBuilderCustomizer jacksonCustomizer() {
return builder -> builder.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
}
}
The error I'm getting:
Caused by: tools.jackson.databind.exc.MismatchedInputException: Cannot map `null` into type `int` (set DeserializationConfig.DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); byte offset: #766] (through reference chain: xxx)
Comment From: snicoll
@mozzer39 it's impossible to say with a few lines of code in text. We don't know how it's being used or how the configuration arrangement works.
If you want support, please take the time to build a small sample, starting from start.spring.io and share it with us with instructions to reproduce that exception. You can attach a zip here or push the code to a GitHub repository.