-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
JsonSubType.Type
should accept array of names
#171
Comments
One immediate concern I have is that type change for Otherwise, either adding this in 3.0 (... but which will take long time to get released...), or adding separate optional So it is important to make sure code that uses annotations can be easily changed; changing |
As far as I know, "abc" is equivalent to [ "abc" ] annotation:
usage:
The output is,
|
@swayamraina Have you actually looked at generated byte-code, or tried cross-compiling one definition (declaring as But what I am worried about is that existing code, compiled to use definition that expects |
So if you are talking about some other lib using these annotations to build something on top. Then yes this would throw a compile time error for them when they upgrade to this version. |
No, not compile time, runtime; and typically via transitive dependencies so it is not necessarily user code that fails during startup (or possibly later), when loading classes. So, two ways here: (1) show that resulting byte code is not different between different declarations (that is, annotation class signature is identical between String/String[]), or (2) create new But beyond that, PR would be needed to make use of new functionality: this may be relatively easy to in |
As an incremental thing, we can go with the second approach you talked about. |
I have a raised a PR : #172 |
@swayamraina Ok it all looks good, and I am ready to merge changes. Just one last thing: before the first contribution (but only then), I'd need CLA: https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf and the usual way is to print it, fill & sign, scan/photo, email to Thank you again for contributing this improvement, looking forward to merging it! |
will submit this in a couple of days! |
JsonSubType.Type
should accept array of names
Merged, will be in 2.12.0. |
the json content is : I have tryed
I mean |
@IrvingZhao you may have accidentally added this in wrong place -- I don't really know how this would be related to the issue at hand. |
多层继承反序列化 场景: translate by baidu Translator Multi level inheritance deserialization Scene: Message data, the first layer, including text message, video message and event message, is distinguished by |
I have read the source of
some like this
|
@IrvingZhao if you need some help regarding usage of the annotations, You can raise a question by creating a new issue. You can provide more details if you mean to point out some bug introduced by this new feature. |
While adding values to JsonSubTypes we have to add each element manually even if multiple keys map to same object.
example:
Current implementation maps one class with one key whereas there are multiple keys in json which can map to same data-structure.
So as per the new feature multiple keys can be mapped to single data-structure without adding multiple entries.
Thoughts?
If this is approved, I am also willing to contribute to this feature.
The text was updated successfully, but these errors were encountered: