Why is there no any method to comment in JSON

This question already has an answer here:

  • Can comments be used in JSON? 42 answers

  • JSON stands for Javascript Object Notation. It simply represents a javascript object. There should be no comments since it is meant to be transferred between client and server or client and client, etc. If you need to express a comment in your object you can either use an Enumerated value, or provide documentation on your data output for whatever process you are doing.

    If you want to represent that this data is a specific type you can do a shorthand, ie:

    {
       "type":"server_response",
       "data":{
                ...
              }
    }
    

    Although if you are interfacing with someone they should usually provide documentation to what values your methods return.

    链接地址: http://www.djcxy.com/p/3386.html

    上一篇: 如何在.json文件中添加注释

    下一篇: 为什么没有任何方法可以在JSON中进行评论