defining different JsonTypeInfo annotations in both the superclass and the subtype results in ambiguity
Search before asking
- [X] I searched in the issues and found nothing similar.
Describe the bug
There is my case:
@JsonTypeInfo(use = Id.NAME, property = "animalType")
@JsonSubTypes({
@Type(value = Humanity.class, name = "mammal")
})
class Animal {
String animalType;
}
@JsonTypeInfo(use = Id.NAME, property = "mammalType")
@JsonSubTypes({
@Type(value = Humanity.class, name = "humanity")
})
class Mammal extends Animal {
String mammalType;
}
class Humanity extends Mammal {
}
I have a JSON string:
{
"animalType": "mammal",
"mammalType": "humanity"
}
I wish to return an instance of the Humanity when I parse the JSON string, but with the version 2.17.1 i am using, I am getting an instance of Mammal returned instead.
Version Information
2.17.1
Reproduction
Expected behavior
No response
Additional context
No response
Subtypes should not try to override @JsonTypeInfo: this is not supported functionality. And as such, results of trying to do that are undefined.
So... I don't think there's necessarily bug to fix. Although example is missing piece of code used for writing/reading json.
Unn... I think it is a new feature. I don't known how much requirement the feature will have, but it is a good enhance to the Jackson.
@wesleyking0 I do not think this is something that should be done, ever. I am ok leaving this open, but currently disagree with the idea fundamentally.