Select Page

Bypassing Comments in JSON!

JSON doesn’t accept comments by default but utilizing the key value pairs, objects and array can be the best tricks to add comments.

Single JSON Comments:

Key Value Pairs are quick way to write single line of comments in JSON.

"my_comment1": "Your comment here"

Curly Bracket JSON Comments:

Generally speaking, Brackets are not designed for commenting in JSON file but you can use this object to group your comments.

"Comment_2": {
"A": "single JSON comments is short and concise"
"B": " {} curly bracket JSON comments is recommended for grouping",
"C": "[] array JSON comments is great for writing a long paragraph"

Array JSON Comments

Array can be a great alternative for writing long comments in JSON file.

"keywords": [
 my comments in JSON file,
can be divided in multiple line,
:D '

Side Note: There no such thing called JSON comments but using the elements in JSON could do the work. See the infographic below to know more about JSON elements. You can also check the detailed documentation from REST API about the syntax of JSON file.

json elements