使用 mlab 添加一个 json 文档(在 heroku 中为 mongodb)

Add a json document with mlab (mongodb in heroku)

我正在尝试使用 heroku 中的 mlab 向我的 mongodb 添加文档:

我收到的消息是:"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."

为什么?谢谢!

由于您没有添加 JSON 的源代码,我建议使用在线 JSON 检查工具,例如 JSONLint.

这可能是您的评论数组中的单引号。

尝试替换为:

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

另外正如@rotemy 所说,如果你对你的 JSON 是否有效有任何疑问,请使用验证器,你将能够更快地解决此类问题