如何看待 JSON 语法中不能加注释的设计?
关注者
162被浏览
354,40922 个回答
是故意的:
https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSrI 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.