Array with trailing comma
- Input
- [1, 2, 3,]
- Expected output
- [1,2,3]
Trailing comma flagged at column 9.
json trailing comma comments
Paste the file with comments or extra commas and turn repair on: every comment and trailing comma removed appears in a list with line and column, and you decide whether to apply the result in the editor.
Trailing comma flagged at column 9.
Comment flagged at line 1, column 10.
Block comment at column 1.
Columns 12, 28 and 30.
Two trailing commas, columns 36 and 38.
The most common causes are a comma after the last item, single quotes, an unquoted key, a comment, and a missing comma between two values. JSON.parse reports only the first problem and, in some browsers, only a character position. This formatter lists every error in the text, each with line and column, shows the snippet with an arrow under the exact spot, marks the line in the editor margin, and has a Go to the error button that selects the spot.
By the standard, no. Some programs read .json as JSONC and tolerate comments, but that is an extension of theirs. If the file goes to JSON.parse, an API or another language, remove the comments first.
Exactly. In JavaScript object and array literals a trailing comma has been allowed for years, and many people copy a literal into a data file. JSON.parse still demands the strict grammar.
It does, because JSON has no place for them. The list of changes shows the line and column of every comment removed, and your original text stays in the editor until you apply the result.
The most common option is a regular string key, such as "_comment". It is valid JSON, but the system that reads the file now sees that key as data, so confirm that it ignores it.