FasterXML / jackson-annotations

Core annotations (annotations that only depend on jackson-core) for Jackson data processor
https://github.com/FasterXML/jackson
Apache License 2.0
1.03k stars 330 forks source link

Document that `@JsonUnwrapped` also applies to deserialization #184

Closed mjustin closed 3 years ago

mjustin commented 3 years ago

The Stack Overflow question What's the Jackson deserialization equivalent of @JsonUnwrapped? currently has 52 upvotes. It is therefore clear that users are surprised to find that @JsonUnwrapped also applies to deserialization.

A prime source of this confusion appears to be the fact that the documentation for @JsonUnwrapped does not mention deserialization at all:

Annotation used to indicate that a property should be serialized "unwrapped"

Other annotations that apply to both serialization & deserialization call this out in the documentation, including @JsonIgnoreProperties, @JsonIgnoreProperties, & @JsonView.

It seems therefore that it would be helpful if the Javadocs mentioned that the annotation applies to deserialization as well as serialization.

cowtowncoder commented 3 years ago

Sounds reasonable: if anyone has time, PR (against branch 2.12, I think) would be very welcome. Unfortunately javadocs mostly get updated when code changes, but in case of annotations code mostly changes in jackson-databind and annotations themselves are not modified, just their applicability.