You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a little 'sensitive data hiding' class that's basically a wrapper class with a custom toString() method.
To make this work with existing classes I registered a custom serialiser that unpacks the value and passes it on. This works great, and if the field is null, the Include.NON_NULL works great as well.
However, when the value inside the wrapper is null, it doesn't get picked up and it still serialises to "fieldname":null. To get around this I have to implement the isEmpty() method in the custom serialiser and use Include.NON_EMPTY on the class that uses the wrapper. This is not bad, but maybe it would be nice to either be able to specify when a field can be considered null with a isFieldNull() or something similar, so you can keep on using NON_NULL and not accidentally remove other fields for being an empty string for example.
I would understand if you'd rather keep it this way to not bloat the interface, but I thought I'd share the idea.
The text was updated successfully, but these errors were encountered:
First of all, thank you for suggesting the idea! I am aware that null handling is (and has been) a challenging part; and further with planning of Jackson 3.x, time is right for possible additions.
I will have to think about this (or something similar to address use case) in context of all changes, as well as in how serializers interact. But it is a good data point, and reminder that improvements would be good in this area.
I've created a little 'sensitive data hiding' class that's basically a wrapper class with a custom
toString()
method.To make this work with existing classes I registered a custom serialiser that unpacks the value and passes it on. This works great, and if the field is null, the
Include.NON_NULL
works great as well.However, when the value inside the wrapper is null, it doesn't get picked up and it still serialises to
"fieldname":null
. To get around this I have to implement theisEmpty()
method in the custom serialiser and useInclude.NON_EMPTY
on the class that uses the wrapper. This is not bad, but maybe it would be nice to either be able to specify when a field can be considered null with aisFieldNull()
or something similar, so you can keep on using NON_NULL and not accidentally remove other fields for being an empty string for example.I would understand if you'd rather keep it this way to not bloat the interface, but I thought I'd share the idea.
The text was updated successfully, but these errors were encountered: