Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json MongoDB语法错误_Json_Mongodb_Syntax - Fatal编程技术网

Json MongoDB语法错误

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",

我在MongoDB中遇到语法问题(SyntaxError:Unexpected token-liked)。该命令是直接从MongoDB指令PDF复制的,我无法找出错误所在

此外,我不知道它是否相关,但我使用的Codeanywhere具有平均堆栈

db.restaurants.insert(
    {
        "address" : {
            "street" : "2 Avenue",
            "zipcode" : "10075",
            "building" : "1480",
            "coord" : [ ­73.9557413, 40.7720266 ],
        },
        "borough" : "Manhattan",
        "cuisine" : "Italian",
        "grades" : [
            {
                "date" : ISODate("2014­10­01T00:00:00Z"),
                "grade" : "A",
                "score" : 11
            },
            {
                "date" : ISODate("2014­01­16T00: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"
}