Can comments be used in JSON?

Created by EliLinked to 37.6m issues across 197 teams

tl;dr

JSON is a data-only format, so it does not support traditional text comments. If you want to include comments, you could create a designated data element called "_comment" that should be ignored by applications that use the JSON data. It is usually better to include comments in the processes that generate or receive the JSON, as they should know what the JSON data will look like in advance. If you do decide to include a comment, it should be written in the following format:

{ "_comment": "comment text goes here...", "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook." "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } } }