Search before asking
Describe the bug
@JsonAlias is ignored when using @jsonvalue, while it works if @jsonvalue is not present.
This is against the documentation.
Version Information
3.1.5
Reproduction
Using this code passing the value "V" in a json raises this exception
tools.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type mypackage.enumeration.Versus from String "V": not one of the values accepted for Enum class: [B, S]
package mypackage.enumeration.Versus;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonValue;
public enum Versus {
@JsonAlias({ "A", "B" }) BUY("B"),
@JsonAlias({ "V", "S" }) SELL("S");
private String value;
Versus(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
}
Expected behavior
Passing "V" or "S" it must return "S".
Additional context
After some researches it seems that EnumResolver.constructUsingMethod() (called only if @jsonvalue is present) doesn't fire findEnumAliases().
Search before asking
Describe the bug
@JsonAlias is ignored when using @jsonvalue, while it works if @jsonvalue is not present.
This is against the documentation.
Version Information
3.1.5
Reproduction
Using this code passing the value "V" in a json raises this exception
tools.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type
mypackage.enumeration.Versusfrom String "V": not one of the values accepted for Enum class: [B, S]Expected behavior
Passing "V" or "S" it must return "S".
Additional context
After some researches it seems that EnumResolver.constructUsingMethod() (called only if @jsonvalue is present) doesn't fire findEnumAliases().