-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Using 2.9.5 version libraries.
Works on simple fields, but no on the keys of the map.
Example:
public class Test {
public void test() throws IOException {
String value = "{" +
" \"Works\" : 1," +
" \"SomeMap\" : {" +
" \"One\" : 1," +
" \"Two\" : 2 +
" }" +
"}";
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
mapper.readValue(value, A.class);
}
}
class A {
@JsonProperty
private Integer works;
@JsonProperty
private Map<MyEnum, Integer> someMap;
}
enum MyEnum {
@JsonProperty("one") ONE,
@JsonProperty("two") TWO
}
Two fields are successfully deserialized: "works" and "someMap", but insides of a map are not.
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize Map key of type
com.test.MyEnumfrom String "One": not a valid representation, problem: (com.fasterxml.jackson.databind.exc.InvalidFormatException) Cannot deserialize Map key of typecom.test.MyEnumfrom String "One": not one of values excepted for Enum class: [one, two]
at [Source: (String)"{ "Works" : "", "SomeMap" : { "One" : "", "Two" : "" }
}"; line: 1, column: 36]
at [Source: (String)"{ "Works" : "", "SomeMap" : { "One" : "", "Two" : "" }
}"; line: 1, column: 36] (through reference chain: com.test.A["SomeMap"])