我有一个名为json_file.json的文件,它看起来像这样:
[
{
"project": "project_1",
"coord1": 2,
"coord2": 10,
"status": "yes",
"priority": 7
},
{
"project": "project_2",
"coord1": 2,
"coord2": 10,
"status": "yes",
"priority": 7
},
{
"project": "project_3",
"coord1": 2,
"coord2": 10,
"status": "yes",
"priority": 7
}
]
当我运行以下命令将其导入到mongodb中时:
mongoimport --db my_db --collection my_collection --file json_file.json
我遇到了以下错误:
Failed: error unmarshaling bytes on document #0: JSON decoder out of sync - data changing underfoot?
如果我在导入命令中添加--jsonArray标志,就像这样:
imported 3 documents
如何使用上面显示的原始文件格式将JSON导入MongoDB,而不是一个带有JSON格式的文档。