我正在尝试用一个JSON来解析一个JSON响应。在下面的例子中,我想知道如何检索'issueId':'executions':'id'的值?在下面的示例中,它是“8195”。。。。。在
r = requests.get(baseURL + getExecutionsForIssueId + id, auth=('user','pass'))
data = r.json()
JSON Response:
{
"status": {
"1": {
"id": 1,
"color": "#75B000",
"description": "Test was executed and passed successfully.",
"name": "PASS"
},
"2": {
"id": 2,
"color": "#CC3300",
"description": "Test was executed and failed.",
"name": "FAIL"
},
"3": {
.
.
.
}
},
"issueId": 15825,
"executions": [
{
"id": 8195,
"orderId": 7635,
"executionStatus": "-1",
"comment": "",
"htmlComment": "",
.
.
.
您的
JSON
对象只是Python中的一个字典。访问您需要的值,如下所示:data['executions']
生成一个类似dictionary对象的数组,假设您的JSON
响应是按预期键入的。在如果您希望遍历它们以找到
^{pr2}$id
为8195的正确对象:相关问题 更多 >
编程相关推荐