我创建了一个demodb.json
文件(有 10 个文档)并将其保存在我的系统D:\
驱动器中
的内容demodb.json
是:
[{"ID": 1,"Name": "Kabul","CountryCode": "AFG","District": "Kabol","Population": 1780000}, {"ID": 2,"Name": "Qandahar","CountryCode": "AFG","District": "Qandahar","Population": 237500}, {"ID": 3,"Name": "Herat","CountryCode": "AFG","District": "Herat","Population": 186800}, {"ID": 4,"Name": "Mazar-e-Sharif","CountryCode": "AFG","District": "Balkh","Population": 127800}, {"ID": 5,"Name": "Amsterdam","CountryCode": "NLD","District": "Noord-Holland","Population": 731200}, {"ID": 6,"Name": "Rotterdam","CountryCode": "NLD","District": "Zuid-Holland","Population": 593321}, {"ID": 7,"Name": "Haag","CountryCode": "NLD","District": "Zuid-Holland","Population": 440900}, {"ID": 8,"Name": "Utrecht","CountryCode": "NLD","District": "Utrecht","Population": 234323}, {"ID": 9,"Name": "Eindhoven","CountryCode": "NLD","District": "Noord-Brabant","Population": 201843}, {"ID": 10,"Name": "Tilburg","CountryCode": "NLD","District": "Noord-Brabant","Population": 193238}]
我的MongoDB位置是:D:\SanMongoDB
我所有的数据库和收藏都存储在D:\SanMongoDB\MongoData
demodb-->city集合的内容如下
{ "_id":ObjectId("51892b40842d69f5fa21962f"),
"Name": "India",
"CountryCode": "IND",
"District": "ODISHA",
"Population": 2050000
}
我启动了 Mongod 服务器,然后打开了 mongo 客户端在 mongo 客户端中,我执行了以下操作:
使用 demodb mongoimport -d demodb -c city --type json --file demodb.json --jsonarray
但我发现错误如下
Thu May 09 08:21:57.861 Javascript execution failed:SyntaxError:Unexpected identifier
请建议我需要做什么,以便我可以轻松地将 Json 文件导入现有的 Mongodb 数据库。