`JsonSubType.Type` should accept array of names
See original GitHub issueWhile adding values to JsonSubTypes we have to add each element manually even if multiple keys map to same object.
example:
@JsonSubTypes({
@JsonSubTypes.Type(name = "not_equals", value = NotEqualsExpression.class),
@JsonSubTypes.Type(name = "ne", value = NotEqualsExpression.class),
@JsonSubTypes.Type(name = "equals", value = EqualsExpression.class)
})
public abstract class Expression { ... }
Current implementation maps one class with one key whereas there are multiple keys in json which can map to same data-structure.
public @interface JsonSubTypes {
JsonSubTypes.Type[] value();
public @interface Type {
Class<?> value();
String name() default "";
}
}
So as per the new feature multiple keys can be mapped to single data-structure without adding multiple entries.
public @interface JsonSubTypes {
JsonSubTypes.Type[] value();
public @interface Type {
Class<?> value();
String[] name() default "";
}
}
Thoughts? If this is approved, I am also willing to contribute to this feature.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
com.fasterxml.jackson.annotation.JsonSubTypes$Type java ...
Id.NAME) @JsonSubTypes({ @Type(name = "I", value = Integer.class), @Type(name = "O", value = Double.class) }) // the annotation will be copied to a...
Read more >JsonSubTypes, list of polymorpic objects and Parcelable
First things first: EXTERNAL_PROPERTY will only work when value is enclosed within another Object (POJO); and will not work for List s, ...
Read more >Jackson Json - @JsonTypeInfo, using Logical Type Name ...
In that case we can use "logical type name" as use = JsonTypeInfo.Id.NAME. In that case name will then need to be separately...
Read more >Type Handling Annotations in Jackson - Javatpoint
It is used for indicating subtypes of types annotated. The @JsonSubTypes annotation is used with @JsonTypeInfo annotation. Let's take an example to understand ......
Read more >JsonTypeInfo “defaultImpl” for collections - Google Groups
Type (value = Dog.class, name = "dog"), @JsonSubTypes. ... It is working on an array at the time but somehow takes the suggestion...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Merged, will be in 2.12.0.
@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
info
at fasterxml dot com. Once I receive it, I can merge changes. CLA itself is good for all future contributions too, it’s just one-time thing we need.Thank you again for contributing this improvement, looking forward to merging it!