Can comments be used in JSON?

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

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

30条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 02:33

    The idea behind JSON is to provide simple data exchange between applications. These are typically web based and the language is JavaScript.

    It doesn't really allow for comments as such, however, passing a comment as one of the name/value pairs in the data would certainly work, although that data would obviously need to be ignored or handled specifically by the parsing code.

    All that said, it's not the intention that the JSON file should contain comments in the traditional sense. It should just be the data.

    Have a look at the JSON website for more detail.

提交回复
热议问题