Skip to content
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

Allow JsonSubTypes binding of several subtypes to one class #652

Closed
TehBakker opened this issue Dec 15, 2014 · 4 comments
Closed

Allow JsonSubTypes binding of several subtypes to one class #652

TehBakker opened this issue Dec 15, 2014 · 4 comments

Comments

@TehBakker
Copy link

I've something like :
@JsonTypeInfo(use = Id.NAME, include = As.PROPERTY, property = "type")
@JsonSubTypes({@JsonSubTypes.Type(value = Mammal.class, name = "Dog"),
@JsonSubTypes.Type(value = Mammal.class, name = "Cat"),
@JsonSubTypes.Type(value = Bird.class, name = "Dodo"},
@JsonSubTypes.Type(value = Bird.class, name = "Cockatoo"})
public class Animal {

}

What I'm seeing right now is that Jackson will only recognize the Dog-to-Mammal and the Dodo-to-Bird mapping. This is because StdSubtypeResolver._collectAndResolve() only allows the same class to get registered once (due to the implementation of NamedType.equals()).

Based on the question at http://stackoverflow.com/questions/18394819/jackson-polymorphism-how-to-map-multiple-subtypes-to-the-same-class following StaxMan advice to create an issue.

@cowtowncoder
Copy link
Member

Duplicate of #312, I think.

@TehBakker
Copy link
Author

Yep, so if i get it right this won't be implemented and i've to make my own deserializer?

@cowtowncoder
Copy link
Member

Not at all, it means that I just want to keep one issue open for same underlying problem. :-)

So I hope that #312 does get implemented eventually. But it has not yet been implemented.

But given that it has not yet been fixed, you may have to write your own deserializer in the meantime (even if implemented, it'd go at earliest in 2.5.0, so it also depends on timing).

@TehBakker
Copy link
Author

Oh sorry, i missread the link that was made from #312 to #652 with the closed icon for #652.
Glad it's not closed.

Thanks for your quick replies. ;)
Yep I'll work something around!

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants