Failed: error unmarshaling bytes on document #0: JSON decoder out of sync - data changing underfoot?

我的 json 文件格式是这样的:

[
    { "name": "张三", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三1", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三2", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三3", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三4", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三5", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三6", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三7", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三8", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] },
    { "name": "张三9", "age": 20, "password": "123456", "email": "[email protected]", "hobbies": ["吃饭", "睡觉", "打豆豆"] }
]

在使用 mongoimport 命令 :

mongoimport -d lyy -c users --file .\user.json

将 json文件导入 mongodb 时,出现以下错误:

在 使用mongoimport将json从文件导入mongodb 中找到了解决办法:

将 --jsonArray 标志添加到命令中:

mongoimport -d lyy -c users --jsonArray  --file .\user.json

发现导入成功:

你可能感兴趣的:(MongoDB)