-
-
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
Support use of @JsonAlias
for enum values
#2352
Comments
Going with the straight forward enum-value pattern is a lot better than the old jdk 6 @XmlElementValue route. Pair it with the composite types <? extends Enum & SomethingElse> for proper power
Given since JDK7 it's all been catered for, I don't think putting in JDK 6 patterns at this point is conducive to moving forward. -1 from me. |
@GedMarc perhaps this was meant for different issue? @RobertDiebels interesting. I can see how this could be useful. |
Sigh, I wish it was as good as that - Sorry guys |
@cowtowncoder Thanks for the reply. I added two sections on behaviour and an example just in case my intentions weren't sufficiently clear.
|
Ok. So, I guess all I am saying is that suggestion is consistent with "main" So in that sense I think request makes sense, and I'd be especially happy to help if anyone wants to implement this. I'll probably eventually get to this myself too, but that may be a while. And as to performance; if implemented by Jackson, annotations are only processed once, to build deserializer, and not every time deserialization occurs. Annotation access is pretty poorly optimized by JDK so anything that has to do it on the fly incurs pretty severe performance penalty. |
@cowtowncoder I'd be happy to take a crack at it. If you could help me get started I'd appreciate that. |
@RobertDiebels I think that |
@cowtowncoder Just letting you know I started working on this. Might take me a while to familiarize myself with the code-base. Hopefully I'll get it done by the end of next week. |
@RobertDiebels excellent! Let me know how it goes -- assuming no API changes needed, may go in a patch, so probably no hurry wrt 2.10.0 release (which needs to go out next week). |
@cowtowncoder I looked at your suggestions for where I could find the alias definitions. Afaics the
The I tried finding a different way to retrieve the aliases by doing the following:
I think I might be able to get this in by adding a constructor to the
Let me know what you think since I'm not sure that's the right way to go about it. |
@RobertDiebels I wish I had more time to look into this, but based on your description it seems legit that aliases would be accessed via I would want to get hold of aliases via |
@cowtowncoder In that case I'll have a crack at exposing the aliases through BeanDescription. Thanks for the reply :D ! |
Sounds good! Also, one thing to note is that if new methods are needed, even in semi-public API, this is still possible for next couple of days: but if so, important thing is to |
@cowtowncoder I'm not sure I can get this done within the next 4 days since I have work in between. I'd suggest to go ahead as planned with the release. I will keep you posted in the mean time. |
Makes sense, we'll see how things go. |
@cowtowncoder This pull-request should get the job done [ /pull/2491 ] let me know what you think. |
Excellent! I'll add this to my work-in-progress list and hopefully have time to review tomorrow. |
Took quite a bit longer, but I am finally merging this in, will be in 2.11(.0). |
@JsonAlias
for enum values
Big thanks to @RobertDiebels for contributing this & apologies for merging taking time. Will be nice addition to 2.11. |
Feature request
Would like to suggest the following feature.
The enabling of @JsonAlias for enums.
Why?
Enabling @JsonAlias for enums can help users that are faced with legacy properties.
Assume that version 0.1.0 has:
and version 0.2.0 has:
Assume both are valid values and we want to map them to one Enum value. Having @JsonAlias available for this purpose can help to avoid bloat-code or custom de-serializers that do this.
Current behaviour
Not implemented.
Expected behaviour
I'd assume the same behaviour as with class members applies. So using @JsonProperty and @JsonAlias combined would yield the same result except for values not keys.
Example
Extra information
Version: 2.9
Occurs in patch: Yes
Feature request was also mentioned in: this issue (Couldn't find the accompanying Feature request)
The text was updated successfully, but these errors were encountered: