简体   繁体   English

mongodb出错。 在属性列表后缺少“}”

[英]Error with mongodb. Missing “}” after property list

with the following code I am getting this error: 使用以下代码我收到此错误:

SyntaxError: missing } after property list <shell>:3

Does anyone know what I did wrong? 有谁知道我做错了什么? The curly braces seem balanced so I am wondering if I made a mistake somewhere else. 花括号看起来很平衡,所以我想知道我是否在其他地方犯了错误。

db.test.save(
{
     "name":"John Doe"
     "attribute":"false"
     "num1":99
     "num2":85
     "num3"{
            "n1":11
            "n2":9
            "n3":8
            "n4":9
     }
     "num4"{
            "m1":15
            "m2":6
            "m3":5
            "m4":12
     }
}
)

Missing colons. 缺少冒号。

 "num3":{
       ^

 "num4":{
       ^

And also commas. 还有逗号。

 "name":"John Doe",
                  ^
 "attribute":"false",
                    ^
 "num3"{
        "n1":11, //commas to separate these object properties too
        "n2":9,
        "n3":8,
        "n4":9
 },
  ^
 //etc

This should execute: 这应该执行:

{
     "name":"John Doe",
     "attribute":"false",
     "num1":99,
     "num2":85,
     "num3":{
            "n1":11,
            "n2":9,
            "n3":8,
            "n4":9
     },
     "num4":{
            "m1":15,
            "m2":6,
            "m3":5,
            "m4":12
     }
}

There are also some examples of valid document s in the MongoDB update docs . MongoDB更新文档中还有一些有效document的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM