While parsing json string as - {"reportingDate":[2017,4,30]}.
I am getting com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
以下是该计划 -
JSON DESERIALIZING CODE -
ObjectMapper mapper = new ObjectMapper();
String dbString = "{\"reportingDate\":[2017,4,30]}";
Map<String, Object> map = new HashMap<String, Object>();
// convert JSON string to Map
map = mapper.readValue(dbString, new TypeReference<Map<String, String>>(){});
System.out.println(map);
答案 0 :(得分:0)
您的JSON
类型引用映射错误,reportingDate
为array
类型,但您将其转换为字符串
更改
map = mapper.readValue(dbString, new TypeReference<Map<String, String>>(){});
要
map = mapper.readValue(dbString, new TypeReference<Map<String, Object>>(){});