-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
enumRelated to handling of Enum valuesRelated to handling of Enum values
Milestone
Description
Using Jackson 2.9.9.3
.
This issue was carried over from micronaut-core: micronaut-projects/micronaut-core#8215
Example test-case:
package arrayissue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.annotation.JsonCreator;
enum MyEnum {
FOO("FOO"),
BAR("BAR");
private String value;
MyEnum(String value) {
this.value = value;
}
public static void main(String[] args) throws JsonProcessingException {
ObjectMapper om = new ObjectMapper();
om.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS);
System.out.println(om.readValue("\"FOO\"", MyEnum.class));
System.out.println(om.readValue("[\"FOO\"]", MyEnum.class));
}
@JsonCreator
public static MyEnum fromValue(String text) {
System.out.println("-- CONVERTING FROM: " + text);
return MyEnum.FOO;
}
}
Result:
-- CONVERTING FROM: FOO
FOO
-- CONVERTING FROM: null
FOO
Metadata
Metadata
Assignees
Labels
enumRelated to handling of Enum valuesRelated to handling of Enum values