我正在从调查猴子api中获取数据,输出如下:
respone= [reponse is a dictionary]
result = response["data"] # result is a list
result:[{ "total_time": 0,"collection_mode": "default","href": "https://api.surveymonkey.com/v3/responses/5007154325",
"custom_variables": {"custvar_1": "one","custvar_2": "two" },"custom_value": "custom identifier for the response","edit_url": "https://www.surveymonkey.com/r/",
"analyze_url": "https://www.surveymonkey.com/analyze/browse/", "ip_address": "",
"pages": [{"id": "103332310", "questions": [{"answers": [{ "choice_id": "3057839051", "row_id" = "3057839851" }],"id": "319352786" }]
{"answers": [{ "choice_id": "3057839061"],"id": "319352786" }]}],"date_modified": "1970-01-17T19:07:34+00:00",
"response_status": "completed","id": "5007154325", "collector_id": "50253586", "recipient_id": "0","date_created": "1970-01-17T19:07:34+00:00",
"survey_id": "105723396" },
{ "total_time": 0,"collection_mode": "default","href": "https://api.surveymonkey.com/v3/responses/5007154325",
"custom_variables": {"custvar_1": "one","custvar_2": "two" },"custom_value": "custom identifier for the response","edit_url": "https://www.surveymonkey.com/r/",
"analyze_url": "https://www.surveymonkey.com/analyze/browse/", "ip_address": "",
"pages": [{"id": "103332310", "questions": [{"answers": [{ "choice_id": "3057838051"}],"id": "319352786" }]
{"answers": [{ "choice_id": "3057839061","row_id" = "3057839851" ],"id": "319352786" }]}],"date_modified": "1970-01-17T19:07:34+00:00",
"response_status": "completed","id": "5007154325", "collector_id": "50253586", "recipient_id": "0","date_created": "1970-01-17T19:07:34+00:00",
"survey_id": "105723396" }....
对于列表中的每个项目,我想将其格式化为多个元素(去规范化),即每个问题和答案都被视为一条记录:
[{"total_time": "0,..........,"pages": "103332310", "questions": "319352786","answers":"3057839051", "row_id" = "3057839851","date_modified": "1970-01-17T19:07:34+00:00",...},
{"total_time": "0",...,"pages": "103332310", "questions": "319352787","answers":"3057839061","date_modified": "1970-01-17T19:07:34+00:00",...}]