Reputation: 71
I'm trying to use Jackson in case to serialize and then deserialize an object. The object contains a field -> protected Serializable data
This is where the problem comes from - this data can come from a lot of components. That is why I'm trying to configure the Jackson ObjectMapper instead of adding annotations and changing the code (because for some of the issues I have with the serialization, like this one, I have to change like hundreds of different classes). Is there any way to tell the ObjectMapper to not use .booleanValue()
on null fields.
This is how I've currently configured my ObjectMapper:
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY)
.withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
Upvotes: 6
Views: 9986
Reputation: 1165
This usually happens when your object has a property definition of type Boolean
but a getter of type boolean
. Ensure these types match.
Upvotes: 6