Json MongoDB语法错误
我在MongoDB中遇到语法问题(SyntaxError:Unexpected token-liked)。该命令是直接从MongoDB指令PDF复制的,我无法找出错误所在 此外,我不知道它是否相关,但我使用的Codeanywhere具有平均堆栈Json MongoDB语法错误,json,mongodb,syntax,Json,Mongodb,Syntax,我在MongoDB中遇到语法问题(SyntaxError:Unexpected token-liked)。该命令是直接从MongoDB指令PDF复制的,我无法找出错误所在 此外,我不知道它是否相关,但我使用的Codeanywhere具有平均堆栈 db.restaurants.insert( { "address" : { "street" : "2 Avenue", "zipcode" : "10075",
db.restaurants.insert(
{
"address" : {
"street" : "2 Avenue",
"zipcode" : "10075",
"building" : "1480",
"coord" : [ 73.9557413, 40.7720266 ],
},
"borough" : "Manhattan",
"cuisine" : "Italian",
"grades" : [
{
"date" : ISODate("20141001T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("20140116T00:00:00Z"),
"grade" : "B",
"score" : 17
}
],
"name" : "Vella",
"restaurant_id" : "41704620"
}
)
尝试替换:
"coord" : [ 73.9557413, 40.7720266 ],
与:
子文档末尾的逗号是额外的
顺便说一下,JSON标准只允许双引号字符串作为属性键,因此,请尝试以下变体:
"coord" : [ "73.9557413", "40.7720266" ]
我使用JSON验证器检查了您的整个JSON文档,以下是一个有效版本:
{
"address": {
"street": "2 Avenue",
"zipcode": "10075",
"building": "1480",
"coord": ["73.9557413", "40.7720266"]
},
"borough": "Manhattan",
"cuisine": "Italian",
"grades": [{
"date": "20141001T00:00:00Z",
"grade": "A",
"score": 11
}, {
"date": "20140116T00:00:00Z",
"grade": "B",
"score": 17
}],
"name": "Vella",
"restaurant_id": "41704620"
}
在
坐标
数组后有多余的逗号。应该是“coord”:[-73.9557413,40.7720266]
好的,所以我删除了多余的逗号,它仍然给我相同的错误。我检查了逗号和括号,没有看到其他内容。缩进在这里起作用还是不起作用?谢谢Mike,是的,这是正确的,我正在试图弄清楚为什么它给了我(src/mongo/shell/types.js:64处的ISO日期无效)我删除了ISO日期,一切都很顺利。
{
"address": {
"street": "2 Avenue",
"zipcode": "10075",
"building": "1480",
"coord": ["73.9557413", "40.7720266"]
},
"borough": "Manhattan",
"cuisine": "Italian",
"grades": [{
"date": "20141001T00:00:00Z",
"grade": "A",
"score": 11
}, {
"date": "20140116T00:00:00Z",
"grade": "B",
"score": 17
}],
"name": "Vella",
"restaurant_id": "41704620"
}