JSON 不支持注释语法,下面是JSON作者道格拉斯·克罗克福特的原话:

I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.

Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. ——— 原文地址

工作中,不同的人做着自己擅长的语言开发,JSON作为一门交换格式语言,没有注释确实是一件悲伤的事情。不过,从另一个角度讲,为了减少沟通成本,我们更应该在意命名,合理的属性命名并不需要注释,这样不是显得更专业吗?

投机取巧

如果你有很强的注释需求,倒是有一个投机取巧的方法:

{
    "_foo": "在这里写注释",
    "foo": "一段看不懂的话",
    "_bar": "在这里写注释",
    "bar": "一段看不懂的话"
}
把注释看做一个属性,属性名添加下划线_前缀(可以是其它字符),对于JSON解析器来说,这个属性同样是一条数据,因为JSON 只能保存数据,只是接受者不使用这个属性而已。