如何看待 JSON 语法中不能加注释的设计?

由于 JSON 中不能使用注释,使其不适合做配置文件,这算是 Douglas 老爷子的设计失误么? JSON「最后不能加逗号」是不是错误设计?
关注者
162
被浏览
354,409

22 个回答

是故意的:

plus.google.com/+Dougla
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.