Can comments be used in JSON?

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

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

30条回答
  •  旧巷少年郎
    2020-11-22 02:26

    You should write a JSON schema instead. JSON schema is currently a proposed Internet draft specification. Besides documentation, the schema can also be used for validating your JSON data.

    Example:

    {
        "description":"A person",
        "type":"object",
        "properties":
            {
                "name":
                    {
                        "type":"string"
                    },
                "age":
                    {
                        "type":"integer",
                        "maximum":125
                    }
            }
    }
    

    You can provide documentation by using the description schema attribute.

提交回复
热议问题