简体   繁体   中英

Add a json document with mlab (mongodb in heroku)

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

使用mlab创建文档

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

Why? Thank you!

由于您未添加JSON的源代码,因此建议您使用在线JSON检查工具(例如JSONLint)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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