我有以下的JSON對象,我希望來遍歷它:迭代通過JSON使用Python
{
"odata.metadata": "https://aaa/_api/$metadata#TimesheetActualData",
"value": [{
"PROJ_UID": "39bf6bca-8939-4df6-aa81-8a6c3b23c979",
"TASK_UID": "48dae88e-59ec-e611-80d4-00155d002a1c",
"ASSN_UID": "4ac8a599-59ec-e611-80d4-00155d002a1c",
"RES_UID": "e4a6a30d-5da2-e611-80cd-00155d00b80f",
"PERIOD_UID": "9a08cd04-7f1c-41f1-9a42-cf9b8b3479ea",
"TS_UID": null,
"PROJ_NAME": "001 - Module Training Project 1",
"TASK_NAME": "Approve new or changed Services",
"TASK_TREE": "> Sample AMS project schedule > Service Strategy > Service Portfolio Management > Approve new or changed Services",
"TASK_TYPE": "Billable",
"TASK_CLIENTID": 9,
"START": "2017-03-05T00:00:00",
"END": "2017-03-05T00:00:00",
"PLANNED_WORK": "0.00",
"PPM_ACTUAL": "0.00",
"TS_ACTUAL": null,
"COMMENT": null,
"SYNC_FLAG": 0,
"APPROVAL_FLAG": null,
"CREATED_DATE": "2017-03-17T12:04:38.53",
"MOD_DATE": "2017-06-09T01:01:42.177",
"ToBeDeleted": 0,
"Incident_No": null,
"Sync_Mod_Date": "2017-06-08T19:31:40",
"TASK_START_DATE": "2017-02-14T08:00:00",
"TASK_FINISH_DATE": "2017-03-10T17:00:00",
"NON_ACTUAL_TASK_FLAG": 0,
"InvoiceMasterId": 0,
"Invoice_Status": "0",
"Billing_Hours": "0.00",
"Billing_Hours_Flag": null,
"Final_Amount": "0.00",
"ProjectCode": null,
"WORKDAY": 0
}, {
"PROJ_UID": "39bf6bca-8939-4df6-aa81-8a6c3b23c979",
"TASK_UID": "48dae88e-59ec-e611-80d4-00155d002a1c",
"ASSN_UID": "4ac8a599-59ec-e611-80d4-00155d002a1c",
"RES_UID": "e4a6a30d-5da2-e611-80cd-00155d00b80f",
"PERIOD_UID": "9a08cd04-7f1c-41f1-9a42-cf9b8b3479ea",
"TS_UID": null,
"PROJ_NAME": "001 - Module Training Project 1",
"TASK_NAME": "Approve new or changed Services",
"TASK_TREE": "> Sample AMS project schedule > Service Strategy > Service Portfolio Management > Approve new or changed Services",
"TASK_TYPE": "Billable",
"TASK_CLIENTID": 9,
"START": "2017-03-06T00:00:00",
"END": "2017-03-06T00:00:00",
"PLANNED_WORK": "0.00",
"PPM_ACTUAL": "0.00",
"TS_ACTUAL": null,
"COMMENT": null,
"SYNC_FLAG": 0,
"APPROVAL_FLAG": null,
"CREATED_DATE": "2017-03-17T12:04:38.7",
"MOD_DATE": "2017-06-09T01:01:42.177",
"ToBeDeleted": 0,
"Incident_No": null,
"Sync_Mod_Date": "2017-06-08T19:31:40",
"TASK_START_DATE": "2017-02-14T08:00:00",
"TASK_FINISH_DATE": "2017-03-10T17:00:00",
"NON_ACTUAL_TASK_FLAG": 0,
"InvoiceMasterId": 0,
"Invoice_Status": "0",
"Billing_Hours": "0.00",
"Billing_Hours_Flag": null,
"Final_Amount": "0.00",
"ProjectCode": null,
"WORKDAY": 0
}],
"odata.nextLink": "https://aaaa/_api/TimesheetActualData?$skip=1000"
}
但不知何故,代碼只是不工作:
header={'content-type': 'application/json'}
response=requests.get(url,headers=header)
jjj=json.dumps(str(response.content))
d=json.loads(jjj)
print(d['values'])
哪一部分無法正常工作?它怎麼不起作用? –
最後一行,我應該得到值數組,然後我應該能夠迭代。 –
使用'd [「值」]' –