Feature summary (what you would like to be able to do and where):
The current JSON linter relies on SyntaxError thrown by the native JSON.parse() function, which varies a lot across browsers. For example, Safari does not even report the location of the error.
In addition, the linter only reports real syntax problems, but duplicate object keys also deserve warnings. Since CodeEditor reports duplicate object keys (T373711#11494778), we may also want to implement it in CodeMirror.
Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
- No error location:
- Open Safari/Chrome/Edge, and edit a JSON page with improved syntax highlighting (CodeMirror 6).
- Replace the content with [x], and the error is reported at the first character instead of before x like in Firefox.
- Another example [01] only fails in Safari, while Firefox/Chrome/Edge reports the error before 1.
- Duplicate object keys (T373711#11494778):
- Edit a JSON page with improved syntax highlighting (CodeMirror 6).
- Replace the content with {"a": 0, "a": 1}, and no error or warning is reported.
Benefits (why should this be implemented?):
Error location is very useful information, and reports of duplicate object keys will also be helpful.