https://www.quora.com/How-do-I-write-comments-inside-a-JSON-document
Comments are not supported with JSON for reasons I consider stupid. BUT, that doesn't mean you can't use them. If you own the recieving application, you might get away with it. I'm using JSON as a configuration file format in the application I'm building at the moment. I have a lot of values I need to let the user set and I don't want to build a custom parser ... so ... I'm using JSON so I can serialize into my object in 1 line of code. Works great for that purpose. Sometimes they want to add comments as to why they are setting value the way they are. In this use case, the reasons for not allowing comments are completely invalid (I think they are always invalid but who cares what I think) ... anyway. I've found that the library I'm using allows /* ... */ comments but doesn't allow // comments.
{
"myObject": { /* this is my first comment that works just fine for me*/
"foo":"bar", /* this is a comment that also works... after comma important */
"foo2":"bar2" // this comment will throw an exception
}
}
Comments are not supported with JSON for reasons I consider stupid. BUT, that doesn't mean you can't use them. If you own the recieving application, you might get away with it. I'm using JSON as a configuration file format in the application I'm building at the moment. I have a lot of values I need to let the user set and I don't want to build a custom parser ... so ... I'm using JSON so I can serialize into my object in 1 line of code. Works great for that purpose. Sometimes they want to add comments as to why they are setting value the way they are. In this use case, the reasons for not allowing comments are completely invalid (I think they are always invalid but who cares what I think) ... anyway. I've found that the library I'm using allows /* ... */ comments but doesn't allow // comments.
{
"myObject": { /* this is my first comment that works just fine for me*/
"foo":"bar", /* this is a comment that also works... after comma important */
"foo2":"bar2" // this comment will throw an exception
}
}