-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 a way to define property name aliases #1029
Comments
In jackson i want to use alternate field. i get response in fullname, fullName,userFullName. No any fixed key.i try jsonAlias but i always get null value.if i make any mistake please met me know. @JsonAlias({"userFullName","fullname","fullName"})
|
@indiascope Please file a new issue with full code to reproduce the problem -- while snippet above is useful it is not enough to reproduce the problem without specifying input and code to call deserialization. |
Thanks for reply. After update project all jackson library to 2.9.0 problem is solved.before update jackson-databind to 2.9.0 jsonAlias not working always get null data. compile 'com.fasterxml.jackson.core:jackson-databind:2.9.0'; |
@indiascope Yes, that would make sense as this feature was added in Jackson 2.9, so earlier versions do not support it. |
Is there also a way to configure the alias feature globally, similar to a |
@sschuberth In future, please ask questions on mailing lists. But no, there is no mechanism for doing that at this point. Naming strategy does one-way transformation at this point. I think the idea has merit, though, and since we are working for Jackson 3.0, perhaps interface could be extended to allow production of aliases too? Could you please file an issue here, outlining your idea (and with a ref back to this issue if it makes sense). |
Although it is possible to use a work-around for accepting alternate property names (by adding secondary setters), it would probably be better to allow an explicit annotation support.
This could be something as easy as:
and would work so that alternative names would be also accepted, but would not be considered the primary name (would not affect serialization for example).
This feature would seem most useful for versioning purposes, to essentially allow for renaming of properties. This is how other formats like Avro handle backwards compatibility.
The text was updated successfully, but these errors were encountered: