Как разложить json ответ
Есть вот такой ответ от сервера
{
"count": 2,
"next": null,
"previous": null,
"msg": "",
"code": 0,
"data": [{
"id": 324,
"emp": 6,
"emp_code": "6",
"first_name": "wsrhedth",
"last_name": null,
"department": "Отдел",
"position": null,
"punch_time": "2024-01-29 07:51:26",
"punch_state": "0",
"punch_state_display": "Приход",
"verify_type": 15,
"verify_type_display": "Лицо",
"work_code": "0",
"gps_location": null,
"area_alias": "123",
"terminal_sn": "CN9B213760020",
"temperature": 0.0,
"is_mask": "Нет",
"terminal_alias": "Auto add",
"upload_time": "2024-01-29 07:51:25"
}, {
"id": 325,
"emp": 7,
"emp_code": "7",
"first_name": "dxgdgh",
"last_name": null,
"department": "Отдел",
"position": null,
"punch_time": "2024-01-29 08:54:28",
"punch_state": "0",
"punch_state_display": "Приход",
"verify_type": 15,
"verify_type_display": "Лицо",
"work_code": "0",
"gps_location": null,
"area_alias": "123",
"terminal_sn": "CN9B213760020",
"temperature": 0.0,
"is_mask": "Нет",
"terminal_alias": "Auto add",
"upload_time": "2024-01-29 08:54:27"
}]
}
Как можно получить 3 переменные по блокам(punch_state,first_name,punch_time), это часть в data? Пробовал так:
response = requests.get(url,params=json, headers=headers)
str = eval(response.text)
str2 = str['id']
print(str)
но такой способ не работает