Reputation: 3016
How can one obtain a default deserialized object in a custom Jackson deserializer?
I have an object which contains some fields which are not to be serialized, but which I wish to always be populated upon deserialization. In other words, a post-deserialize step.
I have created my own deserializer and annotated the class with a corresponding @JsonDeserialize
, but I don't want to deserialize each field in the domain object by hand. Is there a way to get the regular deserialized object so I can just populate my custom fields? (Or else, just register a post-deserialization processor on a bean)
I have seen the answer to this question which hints at an answer, but I'm sufficiently unaware of the Jackson API to determine how best to actually effect this.
Upvotes: 1
Views: 621
Reputation: 3016
This can be achieved by using a BeanSerializerModifier
and extending BeanSerializerBase
, as per @ryanp's answer to this question.
Upvotes: 1