json为什么不允许注释

2018-10-30  本文已影响0人  yancoding

来看看json之父怎么说

image

Comments in JSON
I removed comments from JSON because I saw people were using them to holdparsing directives, a practice which would have destroyed interoperability. I knowthat the lackl of comments makes some people sad, but it shouldn't.
Suppose you are using JSON to keep configuration files, which you would like toannotate. Go ahead and insert all the comments you like. Then pipe it throughJSMin before handing it to your JSON parser.

谷歌翻译一下:

JSON中的注释
我从JSON中删除了注释,因为我看到有人使用它们来保存指令,这种做法会破坏互操作性。 我知道缺乏注释会让一些人感到悲伤,但事实并非如此。
假设您使用JSON来保留您想要注释的配置文件。 继续,插入您喜欢的所有注释。 然后将它传递给JSMin,然后将其传递给JSON解析器。

上一篇 下一篇

猜你喜欢

热点阅读