使用jackson或者fastjson 将json字符串反序列化成对象(以fastjson为例)
TypeReference<AjaxResult<List<Person>>> typeReference = new TypeReference<AjaxResult<List<Person>>>() {};
String json = "{\"code\":200, \"success\":true, \"msg\":\"成功\",\"data\":[{\"name\":\"zhangsan\",\"address\":\"山东青岛\"},{\"name\":\"lisi\",\"address\":\"山东济宁\"}]}";
AjaxResult<List<Person>> listAjaxResult = JSONObject.parseObject(json, typeReference);
System.out.println(listAjaxResult);
restTemplate
restTemplate.exchange() 中ParameterizedTypeReference参数类似
标签:fastjson,TypeReference,listAjaxResult,json,参数,序列化,typeReference From: https://www.cnblogs.com/shareToAll/p/17947197