The "Unexpected comment" error is thrown when JSLint encounters a single-line or
multi-line comment in a JSON string. It will only generate this error when
in JSON mode (it enters JSON mode when the first character of the input is
either {
or [
). In the following example we attempt to comment one of our
JSON properties:
{
"name": "James", // My first name
"age": 24
}
This error is raised to highlight a fatal syntax error. The JSON
specification does not provide any mechanism for comments. Attempting to
deserialize the above example (using JSON.parse
for example) will throw a
syntax error. To solve this issue, simply remove any comments from your JSON:
{
"name": "James",
"age": 24
}