I was practicing JSON, then suddenly, I came across a communication problem which can only be handled using comment so that I could become able to transfer my logical data structure efficiently to other my programming fellows. I google to search out how to comment in JSON, but the answer that I found was "You can't make comments in JSON". So why did JSON developers not add a method to comment in JSON so other developers can perceive the data correctly? I also posted this same question to code project too, hope I will get the desired answer.
JSON stands for Javascript Object Notation. It simply represents a javascript object. There should be no comments since it is meant to be transferred between client and server or client and client, etc. If you need to express a comment in your object you can either use an Enumerated value, or provide documentation on your data output for whatever process you are doing.
If you want to represent that this data is a specific type you can do a shorthand, i.e.:
{
"type":"server_response",
"data":{
...
}
}
Although if you are interfacing with someone they should usually provide documentation to what values your methods return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With