【发布时间】:2020-01-09 07:18:39
【问题描述】:
ObjectMapper mapper = new ObjectMapper();
List<String> stringIds = mapper.readValue(result, new TypeReference<List<String>>(){});
结果 = { “字符串”:[ “ABC”, “xyz” ] }
所以对于输入 {
"stringids": [
"abc",
"xyz"
]
},我希望结果是字符串 abc、xyz 的列表
尝试上述代码时出现此异常:-
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
【问题讨论】:
-
"{"abc", "xyz"}" 不是有效的 JSON。你的意思是“[“abc”,“xyz”]”吗?
-
清道夫,这里的JSON格式我已经更正了