Reputation: 2610
Please explain what is my Parser Error in this JSON object.
db.products.insert({
name: "Microsoft Surface",
category: 'Electronics',
model: '7G5-33333',
})
P.S: JSONLint says, but I can't figure out...
Error: Parse error on line 1:
db.products.insert({
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
Upvotes: 0
Views: 476
Reputation: 10116
Remove the comma at the end (after the model value).
db.products.insert({
name: "Microsoft Surface",
category: 'Electronics',
model: '7G5-33333'
})
Having the comma there indicates there are more key-value pairs, so that's why you're seeing the "missing } after property list" error.
Upvotes: 1
Reputation: 1204
You need something like this:
db.products.insert({
"name": "Microsoft Surface",
"category": "Electronics",
"model": "7G5-33333"
})
Upvotes: 0