我正在使用jackson api解析json响应,我遇到了这个例外,请帮助我 我是杰克逊解析的新手。
json回复:
[{"0":"96859","userid":"96859","1":"fshdh","phoneid":"fshdh","2":"","imageid":""},{"0":"67656656","userid":"67656656","1":"bdndjj","phoneid":"bdndjj","2":"","imageid":""},{"0":"6469895","userid":"6469895","1":"vzbdjn","phoneid":"vzbdjn","2":"","imageid":""},{"0":"6865665","userid":"6865665","1":"hdhdhh","phoneid":"hdhdhh","2":"","imageid":""}]
杰克逊解析:
private User user;
ObjectMapper mapper=new ObjectMapper();
user=mapper.readValue(response, User.class);
答案 0 :(得分:0)
您需要对其进行更改以读取一组用户:
ObjectMapper mapper = new ObjectMapper();
User[] users = mapper.readValue(response, User[].class);