使用 Python,我将 json 文档保存到单独的行中,如下所示:
from bson import json_util # pymongo
with open('test.json', 'ab') as f:
for document in documents:
f.write(json_util.dumps(document)+'\n')
然后像这样阅读:
with open('test.json') as f:
for line in f:
document = json_util.loads(line)
轻松和简单让我觉得一定有一个陷阱?这就是linejson(又名jsonlines )的全部内容吗?