You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Reacted by Grzegorz Dyk, Ben Smith, James Grant, Volodymyr Barna, fadhlan, Bek and ST-DDT
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.
@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.
Is there also a way to configure the alias feature globally, similar to a PropertyNamingStrategy, so that deserialization accepts multiple property names (like undersorces and camel-case)? That would be great for backwards compatibility with existing JSON files when migrating from one naming style to the other.
@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).
Activity
[-](2.8) Add a way to define property name aliases[/-][+]Add a way to define property name aliases[/+]Implement #1029 (add support for `@JsonAlias`)
indiascope commentedon Aug 11, 2017
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"})
private String userFullName;
cowtowncoder commentedon Aug 14, 2017
@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.
indiascope commentedon Aug 16, 2017
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';
compile 'com.squareup.retrofit2:converter-jackson::2.9.0';
compile 'com.fasterxml.jackson.core:jackson-annotations::2.9.0';
cowtowncoder commentedon Aug 16, 2017
@indiascope Yes, that would make sense as this feature was added in Jackson 2.9, so earlier versions do not support it.
sschuberth commentedon Jun 13, 2018
Is there also a way to configure the alias feature globally, similar to a
PropertyNamingStrategy, so that deserialization accepts multiple property names (like undersorces and camel-case)? That would be great for backwards compatibility with existing JSON files when migrating from one naming style to the other.cowtowncoder commentedon Jun 13, 2018
@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).
refactor: align frontend and backend domain terminology (#244)