public static <T> List<T> getObjectsFromJson(String in, Class<T> clsT) throws IOException {
JsonParser parser = objectMapper.getJsonFactory().createJsonParser(in);
JsonNode nodes = parser.readValueAsTree();
List<T> list = new ArrayList<T>(nodes.size());
for(JsonNode node : nodes){
list.add(objectMapper.readValue(node, clsT);
}
}
其中objectMapper一般是这样定义的:
ObjectMapper objectMapper = new ObjectMapper();