Can comments be used in JSON?

后端 未结 30 1696
别跟我提以往
别跟我提以往 2020-11-22 02:16

Can I use comments inside a JSON file? If so, how?

30条回答
  •  感情败类
    2020-11-22 02:33

    Comments were removed from JSON by design.

    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.

    Source: Public statement by Douglas Crockford on G+

提交回复
热议问题