Saturday, 14 September 2013

Setting default values to null fields when mapping with Jackson

Setting default values to null fields when mapping with Jackson

I am trying to map some JSON objects to Java objects with Jackson. Some of
the fields in the JSON object are mandatory(which I can mark with
@NotNull) and some are optional.
After the mapping with Jackson, all the fields that are not set in the
JSON object will have a null value in Java. Is there a similar annotation
to @NotNull that can tell Jackson to set a default value to a Java class
member, in case it is null?

No comments:

Post a Comment