Can I comment on a JSON file? If yes, how?
Can I comment on a JSON file? If yes, how?
No. Unable to comment on JSON.
The ECMA-404 standard, which specifies the JSON standard, does not provide any provisioning for comments.
In cases where comments are strictly necessary, post-parsers can be implemented to manipulate payload in order to eliminate any extra content and keep the output compatible with any services consumers. But there is no established standard.
Sources:
No. It has been made to not contain comments, it is just a data structure formatted as an object.
NOTE If you need some kind of comment, you can insert another field inside your object called comment
or something like ...
The specification does not allow, but if you have already sold your soul to the devil and someone is pointing a gun to your head, you can apply a gambiarra.
For a parser that does not get JSON through streaming , if the same key is declared more than once, the value that will ultimately count whichever comes last. Then, to comment a key, create another key of the same name above it. So:
{
"pessoa": "A pessoa a quem este arquivo se refere",
"pessoa": {
"nome": "O nome da pessoa",
"nome": "John Doe"
}
}
Just emphasizing what I have said before, but in other words: if you do this above you solve a problem now, but you go straight to hell soon after.
I got this idea from SOen's most controversial post to this day: