我正在try 使用终端mongoimports
向mongodb添加一个JSON文件,如下所示:
mongoimport --db my_db --collection my_collection --file /content/2_read.json
我的成绩一直是JavaScript execution failed: SyntaxError: Unexpected identifier
我不确定进口过程中会出现什么问题??或者如何进一步调查以找出问题?
UPDATE
- 有人建议把所有的都放在一条线上.一个不错的建议.我试过了,但没用.
- 我try 导入一个名为
simple.json
的非常简单的json文件,其内容为{'content' : 'simple'}
,但使用mongoimport
仍然会出现相同的错误.(我可以添加mongo
shell中的文档.)
下面是JSON的一个示例.
2_read.json
{
"name" : "John",
"tasks" : [
{
"ix" : "1",
"description" : "description of task",
"tags": []
},
{
"ix": "2",
"description" : "description of task",
"tags" : []
}
]
}
谢谢