I'm trying to add a JSON file to mongodb using mongoimports
from terminal, here:
mongoimport --db my_db --collection my_collection --file /content/2_read.json
I keep getting JavaScript execution failed: SyntaxError: Unexpected identifier
I ran my JSON through JSON Lint: http://jsonlint.com/ which says it's valid JSON.
I'm not sure what could be tripping up the import process?? Or how to investigate further to hunt down the issue?
UPDATE
- Somebody suggested putting all on one-line. A decent suggestion. I tried it and it didn't work.
- I tried importing a very very simple json file named
simple.json
with the content{'content' : 'simple'}
But I'm still getting the same error usingmongoimport
. (I can add documents frommongo
shell just fine.)
A sample of the JSON is below.
2_read.json
{
"name" : "John",
"tasks" : [
{
"ix" : "1",
"description" : "description of task",
"tags": []
},
{
"ix": "2",
"description" : "description of task",
"tags" : []
}
]
}
Thanks.
mongoimports
from the mongo shell prompt instead of the main terminal prompt. After that, I ran into the error of needing --jsonArray (and I got specific errors like in the post your pointed too) Thanks for highlighting that. – Superfluous