我正在尝试将以下名为archived_sensor_data.json
的JSON文件加载到Python中:
[{"timestamp": {"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1475899932.677}, "id": "40898785-6e82-40a2-a36a-70bd0c772056", "name": "Elizabeth Woods"}][{"timestamp": {"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1475899932.677}, "id": "40898785-6e82-40a2-a36a-70bd0c772056", "name": "Elizabeth Woods"}, {"timestamp": {"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1475816130.812}, "id": "2f896308-884d-4a5f-a8d2-ee68fc4c625a", "name": "Susan Wagner"}]
我正在尝试运行的脚本(来自同一目录)如下:
import json
reconstructed_data = json.load(open("archived_sensor_data.json"))
但是,我收到以下错误:
ValueError: Extra data: line 1 column 164 - line 1 column 324 (char 163 - 323)
我不确定这是哪里出错的,因为从www.json.org来看,它似乎是一个字典数组的有效JSON语法。是什么原因导致错误?
答案 0 :(得分:1)
它不是一个有效的json; 这里有两个清单; 一个是
[{"timestamp": {"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1475899932.677}, "id": "40898785-6e82-40a2-a36a-70bd0c772056", "name": "Elizabeth Woods"}]
和另一个
[{"timestamp": {"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1475899932.677}, "id": "40898785-6e82-40a2-a36a-70bd0c772056", "name": "Elizabeth Woods"}, {"timestamp": {"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1475816130.812}, "id": "2f896308-884d-4a5f-a8d2-ee68fc4c625a", "name": "Susan Wagner"}]
您可以在此处看到验证错误; http://www.jsoneditoronline.org/?id=569644c48d5753ceb21daf66483d80cd