-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone

Description
I want to use @JsonCreator to deserialize BigInteger to Enum.
public enum TestEnum {
AAA(BigInteger.valueOf(1)),
BBB(BigInteger.valueOf(2));
private TestEnum(BigInteger key) {
this.key = key;
}
private BigInteger key;
@JsonValue
public BigInteger getKey() {
return this.key;
}
@JsonCreator
public static TestEnum valueOf(BigInteger key) {
/* ... BigInteger to TestEnum ... */
return _enum;
}
}
Now, @JsonCreator compatible with String, Integer, and Long. So, I get IllegalArgumentException.
https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/deser/std/EnumDeserializer.java#L41-L51
and user cannot change EnumDeserializer class (need to custormize BasicDeserializerFactory).
https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java#L1222
I know about @JsonDeserialize and SimpleModule, but they take time applying to each Enums.
Is it possible to add BigInteger deserializing for @JsonCreator ?
Metadata
Metadata
Assignees
Labels
No labels