The fact is, JSON file doesn’t support comments. All the content in the JSON file is data. But still you want to add a comment to your JSON file, You can use the data part as the comment. Which can be ignored during the processing of JSON file.
The JSON file contains values in name/value combination. You can use “_comment” as name part of JSON (just for example) and the comment text as value of this pair, that can be ignored by the JSON parser. Below is the sample JSON file including comments in JSON data.
1 2 3 4 5 6 7 8 9 10 11 | { "_comment": "Your comment string goes here...", "blog": { "name": "TecAdmin", "domain": "tecadmin.net", "founder": "Rahul Kumar", "year": 2013, "niche": "Technology and Computers", "isactive": true } } |
This is not the solution but an option to use comments in a JSON file.
3 Comments
Thanks for sharing information.
Very Nice,
not is beatifull, but work.
Thanks for trick
{
“_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”
}
}
}
}
}