我有一个json字符串,实际上是json对象的数组,我想使用objectMapper将其反序列化为对象列表。我该如何实现?
目前我是这样的:
private ObjectMapper objectMapper = new ObjectMapper();
List<Event> events = readValue(jsonString, MyObject.class);
答案 0 :(得分:1)
尝试一下:
private ObjectMapper objectMapper = new ObjectMapper();
List<Event> events = objectMapper.readValue(jsonString, new TypeReference<List<MyObject>>() {});