Json数据的处理(待补充)

转为对应对象列表

//Json数据:
[
  {
    "id": 1,
    "email": "test",
    "userId": "1233",
    "employeeName": "xx",
    "gender": "MALE",
    "phone": "12341234123",
    "deptName": "外包"
  }
]
//从接口获取Json数据转换
JSONArray jsonArray  = JSON.parseArray(get);
List<Employee> employeeList = jsonArray.toJavaList(Employee.class);
//从文件读取Json数据转换
@Value("xxxx")
private Resource resource;
String jsonData = FileUtil.readInputStream(resource.getInputStream());
List<Employee> employeeList = JSONObject.parseArray(jsonData, Employee.class);
posted @ 2022-02-10 16:21  zjcfrancis  阅读(14)  评论(0编辑  收藏  举报