org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList o
使用jackson解析,出现问题
待解析json
{"name":"myEnterprise", "departments":["HR"]}
解析异常
ATTENTION: /enterprise/enterprise: org.codehaus.jackson.map.JsonMappingException:
Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token at
解析的代码
public <T> T fromJson(String jsonString, Class<T> clazz) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return mapper.readValue(jsonString, clazz);
} catch (IOException e) {
logger.warn("parse json string error:" + jsonString, e);
return null;
}
}
TbLtTourOrderGuest[] togs = jsonBinder.fromJson(addGuests, TbLtTourOrderGuest[].class);
排查了下,原来是json字符串的问题
应该是
[{"name":"myEnterprise", "departments":["HR"]}]