question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why is @JsonTypeResolver separate from @JsonTypeInfo ?

See original GitHub issue

It 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:closed
  • Created 11 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bytesandwichcommented, Aug 3, 2012

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.

0reactions
cowtowncodercommented, Mar 17, 2014

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found