Search before asking
Describe the bug
I'm trying use @JsonAlias on a class which is a member of a type hierarchy, and then expecting Jackson Databind to be able to use the alias to determine the type.
My class hierarchy is Deduction, annotated with its two concrete implementations:
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
@JsonSubTypes({
@JsonSubTypes.Type(value = DeductionBean1.class),
@JsonSubTypes.Type(value = DeductionBean2.class)
})
where DeductionBean2 uses an alias.
record DeductionBean2(@JsonAlias("Y") int y) implements Deduction {
}
This fails like so when deserializing {'Y': 2 }
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class com.fasterxml.jackson.databind.deser.PropertyAliasTest$Deduction]: Cannot deduce unique subtype of `com.fasterxml.jackson.databind.deser.PropertyAliasTest$Deduction` (2 candidates match)
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 9]
Version Information
2.17
master
Reproduction
I've added a test tools.jackson.databind.deser.PropertyAliasTest#testAliasWithPolymorphicDeduction that demonstrates the issue I face.
k-wall@8380c94
Expected behavior
Aliases to be respected by DEDUCTION.
Additional context
No response
Search before asking
Describe the bug
I'm trying use
@JsonAliason a class which is a member of a type hierarchy, and then expecting Jackson Databind to be able to use the alias to determine the type.My class hierarchy is Deduction, annotated with its two concrete implementations:
where
DeductionBean2uses an alias.This fails like so when deserializing
{'Y': 2 }Version Information
2.17
master
Reproduction
I've added a test tools.jackson.databind.deser.PropertyAliasTest#testAliasWithPolymorphicDeduction that demonstrates the issue I face.
k-wall@8380c94
Expected behavior
Aliases to be respected by
DEDUCTION.Additional context
No response