在Ubuntu中,我有几个文件夹,里面有json文件,我尝试将它们导入到mongo数据库中。为什么我在我尝试的特定文件夹中:
ls -1 *.json | while read jsonfile;
do mongoimport --db mydb --collection logs --file $jsonfile --jsonArray --type json;
done但我得到一个错误:
Failed: error reading separator after document #1: bad JSON array format -
found no opening bracket '[' in input source在json文件没有包含在[]中的情况下,我有什么想法可以做这样的导入吗?另外,如果有人知道如何遍历父映射中的所有映射(包含json文件),将不胜感激。
诚挚的问候
发布于 2016-09-11 22:45:55
问题出在--jsonArray选项上。我把它移走了,它起作用了。请参阅mongodb not importing json as expected
https://stackoverflow.com/questions/39437132
复制相似问题