我有一組JSON數據,看起來simular這樣:搜索JSON,JSON的結構內返回字符串
{"executions": [
{
"id": 17,
"orderId": 16,
"executionStatus": "1",
"cycleId": 5,
"projectId": 15006,
"issueId": 133038,
"issueKey": "QTCMP-8",
"label": "",
"component": "",
"projectKey": "QTCMP",
"executionDefectCount": 0,
"stepDefectCount": 0,
"totalDefectCount": 0
},
{
"id": 14,
"orderId": 14,
"executionStatus": "1",
"cycleId": 5,
"projectId": 15006,
"issueId": 133042,
"issueKey": "QTCMP-10",
"label": "",
"component": "",
"projectKey": "QTCMP",
"executionDefectCount": 0,
"stepDefectCount": 0,
"totalDefectCount": 0
}
],
"currentlySelectedExecutionId": "",
"recordsCount": 4
}
我曾與Python採取了這一點,並解析它,如下:
import json
import pprint
with open('file.json') as dataFile:
data = json.load(dataFile)
有了這個,我能夠通過執行數據[「執行」]等方式找到像執行這樣的數據集。我需要做的是在結構中搜索字符串「QTCMP-8」,然後當我找到特定的字符串,找到與該字符串關聯的「id」。所以在QTCMP-8的情況下,它將是ID 17;對於QTCMP-10它將是14.
這可能嗎?我需要先轉換數據嗎?任何幫助是極大的讚賞!
你需要確認與'issueKey'鍵或'projectKey' –
值假設你需要'issueKey',根據你上面提供的例子添加一個答案 –