{ "code": 1, "msg": "操作成功", "obj": { "resType": "application", "userAccount": "dw_chenx", "mobile": "13160036215", "authApps": [{ "authStartDate": 1675655764000, "resType": "application", "authEndDate": 1833422164000, "remark": null, "authFlag": 0, "resId": 2000105, "rootTicket": "36b0e21d09c641989f3a8573957a899d", "subAccount": "dw_chenx" }], "resId": 2000105 }, "success": true, "operateObj": null, "token": null }如何获取rootTicket值
时间: 2023-08-10 15:09:29 浏览: 402
要获取 `rootTicket` 的值,可以使用 json 解析库(如 Python 中的 json 模块)来解析返回的 JSON 格式数据,并从中提取所需的值。在 Python 中,可以使用如下代码来实现:
```python
import json
response_body = '{ "code": 1, "msg": "操作成功", "obj": { "resType": "application", "userAccount": "dw_chenx", "mobile": "13160036215", "authApps": [{ "authStartDate": 1675655764000, "resType": "application", "authEndDate": 1833422164000, "remark": null, "authFlag": 0, "resId": 2000105, "rootTicket": "36b0e21d09c641989f3a8573957a899d", "subAccount": "dw_chenx" }], "resId": 2000105 }, "success": true, "operateObj": null, "token": null }'
json_data = json.loads(response_body)
root_ticket = json_data['obj']['authApps'][0]['rootTicket']
print(root_ticket)
```
以上代码将输出 `36b0e21d09c641989f3a8573957a899d`,即为 `rootTicket` 的值。
阅读全文