db.students.insertone({“_id”:1001,“firstname”:“john”,lastname:“smith”,地址:{streetaddress:“123 Monash Drive”,郊区:“Clayton”,州:“Vic”,邮编:3168},性别:“男性”,课程:“bits”,年份:2019,校外:“false”,电子邮件:[“jsmith@gmail.com”,“jsmith@yahoo.com”]})键入这些后,我得到了未捕获异常的错误:syntaxerror:missing:After property id:。Idk为什么会这样。
您试图插入的文档不是有效的JSON,请尝试以下操作-
db.students.insertOne({
"_id": 1001,
"Firstname": "John",
"Lastname": "smith",
"Address": {
"Streetaddress": "123 Monash Drive",
"Suburb": "Clayton",
"State": "VIC",
"Postcode": 3168
},
"Gender": "Male",
"Course": "BITS",
"Year": 2019,
"Off-Campus": "false",
"Email": [
"jsmith@gmail.com",
"jsmith@yahoo.com"
]
});