我有一个巨大的 JSON 文件,最初来自 MongoDB。
该文件包含几种 MongoDB 类型,例如:
"_id" : ObjectId("55a3490924012c2ab7a46f76"),
"year" : NumberInt(1975),
由于它们,我无法通过以下方式将其加载到 MongoDB 数据库中mongoimport
:
Failed: invalid JSON input. Position: 17. Character: O
请注意,上面的“字符:O”是“ObjectID”的第一个“O”。
我也不能使用 ijson Python 包:
import ijson
filepath = 'bigdata.publication.json'
f=open(filepath,'r',encoding="utf-8")
for id in ijson.items(f,'url'):
print(id)
错误信息:ijson.backends.python.UnexpectedSymbol: Unexpected symbol 'O' at 15
。
有没有其他方法来解析 JSON 文件?