Susana Mar Flores
Susana Mar Flores

Reputation: 2478

Add a json document with mlab (mongodb in heroku)

I´m trying to add a document to my mongodb with mlab in heroku:

Create document with mlab

And the message I get is: "JSON Validation Error: We encountered an error while parsing your JSON. Please check your syntax (e.g. ensure you are using double quotes around both your field names and values) and try again."

Why? Thank you!

Upvotes: 0

Views: 2373

Answers (2)

andresk
andresk

Reputation: 2845

It's probably the single quotes on your comments array.

Try replacing with:

"comments": [
  {
    "comment": "This is insane",
    "author": "Matt Daemon"
  }
]

Also as @rotemy said, you have any doubts if your JSON is valid, use a validator and you will be able to solve this kind of issues much faster

Upvotes: 1

Rotem
Rotem

Reputation: 1379

Since you didn't add the source code of your JSON, I would recommend using online JSON checking tool such as JSONLint.

Upvotes: 2

Related Questions