在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文件)在父地图,这将是感激。
问题是--jsonArray
选项。我把它拆了,它还能用。见mongodb未按预期导入json