Replies: 1 comment 1 reply
-
For backwards-compatibility reasons there is I think your use case -- essentially, content transformation when remapping names -- falls outside of Jackson's goals; specifically 2 functionality areas are kept out for the most part:
If you do want to use Jackson for name translation, you could probably construct separate I think it is unlikely that support would be added for different sets of names for serialization/deserialization, beyond existing set of annotations. |
Beta Was this translation helpful? Give feedback.
-
Why is it not possible to specify whether
@JsonProperty
should be used for deserialization, serialization or both?In my case, I want to create a DTO that maps fields from another API.
The intention was to map the fields to a more readable, consistent version and then return it to the client. However,
@JsonProperty
applies to both deserialization and serialization. The client receives the DTO in the same way as the server received it from the external system.I can fix this by creating another DTO that can be constructed with the one from the example, but it feels like a bit of a tedious solution. In this case, I would have preferred something in the lines of
@JsonProperty("optionID", onSerialization = false)
.Beta Was this translation helpful? Give feedback.
All reactions