我有一个包含大量 JSON(此处缩写)的列表,它们非常嵌套,我想对其进行规范化并将其全部提升到 JSON 中的一个级别。
我有:
[{'index': 'exp-000005',
'type': '_doc',
'id': 'jdaksjdlkj',
'score': 9.502488,
'source': {'user': {'resource_uuid': '123'},
'verb': 'REPLIED',
'resource': {'resource_uuid': '/home'},
'timestamp': '2022-01-20T08:14:00+00:00',
'with_result': {},
'in_context': {'screen_width': '3440',
'screen_height': '1440',
'build_version': '7235',
'clientid': '123',
'question': 'Hallo',
'request_time': '403',
'status': 'success',
'response': '[]',
'language': 'de'}}},
{'index': 'exp-000005',
'type': '_doc',
'id': 'dddddd',
'score': 9.502488,
'source': {'user': {'resource_uuid': '44444'},
'verb': 'REPLIED',
'resource': {'resource_uuid': '/home'},
'timestamp': '2022-01-20T08:14:10+00:00',
'with_result': {},
'in_context': {'screen_width': '3440',
'screen_height': '1440',
'build_version': '7235',
'clientid': '345',
'question': 'Ich brauche Hilfe',
'request_time': '111',
'status': 'success',
'response': '[{"recipientid":"789", "text":"Bitte sehr."}, {"recipientid":"888", "text":"Kann ich Ihnen noch mit etwas anderem behilflich sein?"}]',
'language': 'de'}}},
{'index': 'exp-000005',
'type': '_doc',
'id': 'jdhdgs',
'score': 9.502488,
'source': {'user': {'resource_uuid': '333'},
'verb': 'REPLIED',
'resource': {'resource_uuid': '/home'},
'timestamp': '2022-01-20T08:14:19+00:00',
'with_result': {},
'in_context': {'screen_width': '3440',
'screen_height': '1440',
'build_version': '7235',
'clientid': '007',
'question': 'Zertifikate',
'request_time': '121',
'status': 'success',
'response': '[{"recipientid":"345", "text":"Künstliche Intelligenz"}, {"recipientid":"123", "text":"Kann ich Ihnen noch mit etwas anderem behilflich sein?"}]',
'language': 'de'}}}]
我想要什么:
[{'index': 'exp-000005',
'type': '_doc',
'id': 'jdaksjdlkj',
'score': 9.502488,
'resource_uuid': '123',
'verb': 'REPLIED',
'resource_uuid': '/home',
'timestamp': '2022-01-20T08:14:00+00:00',
'with_result': {},
'screen_width': '3440',
'screen_height': '1440',
'build_version': '7235',
'clientid': '123',
'question': 'Hallo',
'request_time': '403',
'status': 'success',
'response': '[]',
'language': 'de'},
{'index': 'exp-000005',
'type': '_doc',
'id': 'dddddd',
'score': 9.502488,
'resource_uuid': '44444',
'verb': 'REPLIED',
'resource_uuid': '/home',
'timestamp': '2022-01-20T08:14:10+00:00',
'with_result': {},
'screen_width': '3440',
'screen_height': '1440',
'build_version': '7235',
'clientid': '345',
'question': 'Ich brauche Hilfe',
'request_time': '111',
'status': 'success',
'recipientid1': "789",
'text1': "Bitte sehr",
'recipientid2': "888",
'text2': "Kann ich Ihnen noch mit etwas anderem behilflich sein?",
'language': 'de'},
{'index': 'exp-000005',
'type': '_doc',
'id': 'jdhdgs',
'score': 9.502488,
'resource_uuid': '333',
'verb': 'REPLIED',
'resource_uuid': '/home',
'timestamp': '2022-01-20T08:14:19+00:00',
'with_result': {},
'screen_width': '3440',
'screen_height': '1440',
'build_version': '7235',
'clientid': '007',
'question': 'Zertifikate',
'request_time': '121',
'status': 'success',
'recipientid1': "345",
'text1': "Künstliche Intelligenz",
'recipientid1': "123",
'text2': "Kann ich Ihnen noch mit etwas anderem behilflich sein?",
'language': 'de'}]
我不确定是否使用 JSON 扁平化或 pandas 规范化的一些魔法。