我能否在以下发言中发表一些意见?Json Json (Json Json) (Json Json Json) (Json Json) Json Json (Json Json) Json (Json) Json (Json) Json (Json) Json (Json) Json (Json) Json (Json) Json(Json) Json (Json) Json (Json) Json(Json) Json (Json) Json如果有,如何处理?


当前回答

JSON并不是一个框架化协议。它是一个语言自由格式。因此没有为 JSON 定义评论格式。

正如许多人所暗示的那样,有一些把戏,例如重复键或特定键。_comment你可以使用它,由你决定

其他回答

JSON和JSON需要提出评论。至少可在.NET Core 中提供评论。JSON和牛顿软JSON 工作很顺利

{
  // this is a comment for those who is ok with being different
  "regular-json": "stuff"...
}

如果您正在使用杰克逊JSON作为您的 JSON 分析者, 那么这就是你如何 允许它 允许评论:

ObjectMapper mapper = new ObjectMapper().configure(Feature.ALLOW_COMMENTS, true);

然后,你可以有这样的评论:

{
  key: "value" // Comment
}

您也可以从#通过设定:

mapper.configure(Feature.ALLOW_YAML_COMMENTS, true);

但总的来说(如前所述),规格不允许作出评论。

包含备注, 如果您选择的话; 在解析或传输前用一个分解符将其删除 。

我刚放出来JSON. 最小化 ()将评论和空格从JSON的一块块中除去,使JSON能够被解析,成为有效的JSON。

JSON.parse(JSON.minify(my_str));

当我发布时,我得到了一股巨大的反感, 许多人甚至不同意这个想法, 所以我决定写一篇全面的博客文章, 说明为什么JSON认为,它包括JSON创始人的这一引人瞩目的评论:

假设您正在使用 JSON 保存配置文件, 您想要对此进行注释 。 请继续插入您想要的所有评论 。 然后通过 JSMIN 管道将其传送给您的 JSON 分析者 。 - 将它交给您 JSON 分析者 。Douglas Crockford,2012年

希望这样能帮助那些不同意为什么JSON. 最小化 ()可能有用。

否 无表格、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、表格评论、//…/*…*/在 JSON 中不允许 。 此答案基于 :

  • https://www.json.org
  • RFC 4627: 变化:application/jsonJavaScript 对象标记( JSON) 的介质类型
  • RFC 8259JavaScript 对象标记(JSON)数据交换格式(取代RFCs 4627、7158、7159)

这是我在Google 火底文件允许你对JSON发表评论:

{
  "//": "Some browsers will use this to enable push notifications.",
  "//": "It is the same for all projects, this is not your project's sender ID",
  "gcm_sender_id": "1234567890"
}