-
-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @JsonWrapped (to complement @JsonUnwrapped) #42
Comments
You are right in that annotation itself would be added here, but none of code handling it will be, which is why I think databind is actually better place for this. As to multiple levels, I thought about that, and if that was to be supposed, I don't think we can assume '.' can be used as separator, since it is a legal property name character.
and Java annotations also allow omitting arrays to just do single as well
|
👍 |
2 similar comments
👍 |
+1 |
+1. I'd love if this were added to @JsonProperty({"address", "housenumber"}) |
This would save a lot of boilerplate. +1 |
👍 |
I would also like to see this feature. |
Currently custom serialializer/deserializer would be the way to go. Or possibly converting serializer/deserializer using disposable wrapper classes. |
+1 for @JsonWrapped({ "contact_details", "address" }) |
+1 |
+1 |
2 similar comments
+1 |
+1 |
Enough voting -- locking issue for now, hoping github will add something better than needing to add more +1 comments. :) |
Unlocking to allow use of reactions (use "thumbs up" to "vote"). Please no "+1" comments (content-containing comments welcome of course). |
Re-rasing this issue from the old Jira bug tracker: https://jira.codehaus.org/browse/JACKSON-781
It was suggested this should be raised in the data bind project, but as it is an annotation, this seemed a better fit.
This is the original issue description:
I agree this would be a great feature to avoid unnecessary wrappers on the Java side when consuming JSON APIs.
I'd picture a new annotation that would take a form along the lines of:
or it could be an additional parameter of the
@JsonProperty
annotation:or, possibly, the value parameter of the
@JsonProperty
annotation could specify the object hierarchy:This may introduce backwards compatibility issues, though, as it would mean this behaved differently than it currently does.
It would be good if it could also unwrap multiple levels, such as:
Though, this would mean the value of the
@JsonWrapped
annotation was parsed differently than the value of the@JsonProperty
annotation (as"contact_details.address"
in the@JsonProperty
annotation would refer to an object key named "contact_details.address").The text was updated successfully, but these errors were encountered: