Why is @JsonTypeResolver separate from @JsonTypeInfo ?
See original GitHub issueIt seems in JacksonAnnotationIntrospector
that @JsonTypeResolver
cannot exist without @JsonTypeInfo
protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config,
Annotated ann, JavaType baseType)
{
...
JsonTypeInfo info = ann.getAnnotation(JsonTypeInfo.class);
JsonTypeResolver resAnn = ann.getAnnotation(JsonTypeResolver.class);
if (resAnn != null) {
if (info == null) {
return null;
}
Unless I misunderstood this, I think it is unnecessary and confusing.
Issue Analytics
- State:
- Created 11 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Deserialize JSON with Jackson into Polymorphic Types
This line means: add a meta-property on serialization or read a meta-property on deserialization ( include = JsonTypeInfo.
Read more >More Jackson Annotations - Baeldung
The @JsonTypeId annotation is used to indicate that the annotated property should be serialized as the type id when including polymorphic type ......
Read more >Using @JsonTypeInfo annotation to handle polymorphic types
Using @JsonTypeInfo. This annotation is used to serialize information about actual class of polymorphic instances, so that Jackson can know what ...
Read more >JsonTypeInfo.java - Android Code Search
Means that logical type name is used as type information; name will then need. * to be separately resolved to actual concrete type...
Read more >JsonTypeInfo.java example - Javatips.net
JsonTypeResolver } annotation. * * @see org.codehaus.jackson.map.annotate.JsonTypeResolver * @since 1.5 * * @author tatu */ @Target({ElementType.
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
Sorry for not explaining very well. When I read the javadoc, I thought typeResolver would generally be able to handle type information. Basically I thought it would should have the functionality required for #43. I was surprised when I looked at the unit tests and found that it relies on typeinfo.
As it does not exist without jsontypeinfo, I would think it logical to have an additional field in type info, and maybe rename type info, rather than adding this dependent second annotation. That way, the annotation encapsulates a logically complete unit of metadata.
I was thinking that if I use include Id.NONE then register a typeResolver to inspect the bean, I could get what I want. You suggested that TypeResolver wasn’t intended for this purpose, but I think it would be more intuitive to restructure these two annotations, particularly if things are being uprooted for #43.
I don’t thing we should change this interaction without specific reasons, as backwards compatibility with existing customizations is very important. Closing this for now; can re-open if revisiting is needed.