Search code examples
jsonmacosmongodbimportmongoimport

Importing json documents into mongodb on mac


I am getting an error while importing a json document into mongoDB installed on my mac. I saw on another forum that the syntax is as follows:

mongoimport --db db1 --collection collection1 --file /Users/chummi/Desktop/zips.json

Here db1 is my database and collection1 is my collection and /Users/chummi/Desktop/zips.json is the path where the json document is present. When I run this command, am getting the following error

"SyntaxError: Unexpected identifier"

and not able to understand what this is.Please suggest if the syntax and the paths are correct?


Solution

  • Are you running mongoimport from inside the mongodb shell instead of the command line of your mac? Importing JSON file using mongimport, keep getting `unexpected identifier`?