使用以下代码我收到此错误:
SyntaxError: missing } after property list <shell>:3
有谁知道我做错了什么?花括号似乎是平衡的,所以我想知道我是否在其他地方犯了错误。
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
}
}
)
答案 0 :(得分:4)
缺少冒号。
"num3":{
^
"num4":{
^
还有逗号。
"name":"John Doe",
^
"attribute":"false",
^
"num3"{
"n1":11, //commas to separate these object properties too
"n2":9,
"n3":8,
"n4":9
},
^
//etc
这应该执行:
{
"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
}
}
MongoDB update docs中还有一些有效document
的例子。