如上是POST调回的JSON串,要取得deptCode的值,返回值要JSON格式写

{
  "status": 0,
  "data": {
    "deptId": 76,
    "deptCode": "101030000",
    "deptName": "成都工务段",
    "dirDeptCode": "100000000",
    "deptLevel": 2,
    "defaultRoleId": 1,
    "createAt": "2021-02-25 02:18:51",
    "updateAt": "2021-03-03 09:09:35",
    "defaultRoleName": "系统超级管理员"
  }
}

如上是POST调回的JSON串,要取得deptCode的值,返回值要JSON格式写,怎么写😭

res.data.deptCode,res为你返回的json的定义

解析成jsonobject对象,或者map,然后获取

    JSONObject jsonObject=JSONObject.parseObject(json); //你的字符串
    System.out.println(jsonObject.getJSONObject("data").get("deptCode"));  //返回 101030000

xxx.data..deptCode