-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
Using a factory method having multiple arguments annotated with @JsonCreator works normally when the factory is for a class type, but fails if the factory is for an enum type.
jackson-databind v 2.5.1
jackson-annotations v 2.5.0
e.g. code
String json = "{\"intProp\":1,\"stringProp\":\"first\"}";
ObjectMapper mapper = new ObjectMapper();
MyClass classValue = mapper.readValue(json, MyClass.class); //works
MyEnum enumValue = mapper.readValue(json, MyEnum.class); //fails
both MyClass and MyEnum has a method like
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public static MyClass/MyEnum forValues(@JsonProperty("intProp") int intProp, @JsonProperty("stringProp") String stringProp){
/// logic to create an instance with params using int
// in case of enum find the appropriate object.
return object;
}
johnjohndoe
Metadata
Metadata
Assignees
Labels
No labels