cat*_*aki 29 mongodb mongoimport
我正在尝试使用mongoimports终端向mongodb添加一个JSON文件,这里:
mongoimport --db my_db --collection my_collection --file /content/2_read.json
Run Code Online (Sandbox Code Playgroud)
我一直在JavaScript execution failed: SyntaxError: Unexpected identifier
通过JSON Lint运行我的JSON:http://jsonlint.com/ ,它说它是有效的JSON.
我不确定什么可能绊倒导入过程?或者如何进一步调查以追捕这个问题?
UPDATE
simple.json内容命名的json文件{'content' : 'simple'}但是我仍然使用相同的错误mongoimport.(我可以从mongoshell 添加文件就好了.)下面是JSON的示例.
2_read.json
{
"name" : "John",
"tasks" : [
{
"ix" : "1",
"description" : "description of task",
"tags": []
},
{
"ix": "2",
"description" : "description of task",
"tags" : []
}
]
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
cat*_*aki 125
回答我自己的问题,因为完整的新手会理解错误,并可能在开始时遇到错误.
mongoimport从终端使用,不在mongoshell中使用.就像你不使用npm里面node.; d
在弄清楚我的概念错误后,我需要@WiredArray在评论中指出@WiredPrairie.
| 归档时间: |
|
| 查看次数: |
17772 次 |
| 最近记录: |