Jason Z Jason Z - 1 year ago 209
JSON Question

SyntaxError: Unexpected identifier while importing JSON file in MongoDB

mongoimport --db test --collection collection1 --file c:/test.json

I got SyntaxError: Unexpected identifier when executing the above command.

What is the problem of this script?

Thank you very much

Answer Source

I had the same issue when i tried to import json file from MongoDB Shell.
You can query it from command prompt.
My directory stucture:

C:\Program files\MongoDB\Server\3.0\bin\mongoimport.exe  


C:\Program Files\MongoDB\Server\3.0\bin> ./mongoimport --db dbname --collection collection_name C:\filename.json  

Output should be:

2015-08-18T09:34:25.617-0700    connected to: localhost
2015-08-18T09:34:25.632-0700    imported 10 documents

Now switch back to MongoDB Shell:

 C:\Program Files\MongoDB\Server\3.0\bin> ./mongo
 use dbname
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download