Reputation: 2364
How to import a json file to mongodb? I tried:
mongoimport --db test --collection restaurants --drop --file primer-dataset.json
Upvotes: 1
Views: 452
Reputation: 21766
mongoimport is a stand-alone application that needs to be executed from the shell, (Window Command Prompt, Bash, etc). It seems you are currently executing the code inside the Mongo shell itself.
Upvotes: 3
Reputation: 37048
The docs read:
The mongoimport tool imports content from an Extended JSON, CSV, or TSV export created by mongoexport, or potentially, another third-party export tool.
The word "potentially" means it should be a valid json with expected structure. Not an arbitrary json.
Upvotes: 1