-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
I have a simple test code:
@Data
public class The {
private String the;
private Map<String, Integer> the2;
private The the3;
public static void main(String[] args) throws Exception {
final ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS);
// Cannot deserialize instance of `java.util.LinkedHashMap<java.lang.Object,java.lang.Object>` out of START_ARRAY token
// final String json = "{\"the\":[\"a\"],\"the2\":[{\"a\":1,\"b\":2}],\"the3\":[{\"the\":\"aaa\"}]}";
final String json = "{\"the\":[\"a\"],\"the2\":{\"a\":1,\"b\":2},\"the3\":[{\"the\":\"aaa\"}]}";
System.out.println(json);
final The v = mapper.readValue(json, The.class);
System.out.println(mapper.writeValueAsString(v));
}
}
Using the first json will cause com.fasterxml.jackson.databind.exc.MismatchedInputException
, but using the next json has no problem.
It seems that DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS
doesn't support a Map
type field. Is this a bug?
My jackson-databind
version: 2.10.4
Metadata
Metadata
Assignees
Labels
No labels