Page MenuHomePhabricator

Make code editor understand JSON with comments and trailing commas
Open, Needs TriagePublic

Description

MediaWiki uses a more relaxed form of JSON that permits both // style comments and unneeded trailing commas. But codeeditor that we use to edit that json shows error on the first comment or comma, and does not show any real errors. This is especially evident when designing a new graph in https://en.wikipedia.org/wiki/Special:GraphSandbox

Event Timeline

TheDJ subscribed.

This will need to be filed with the Ace project.

Comments and trailing commas are supported in JSON5, and JSON5 support seems to have been added to Ace in 2019.

Automatically fixing missing and trailing commas when the user saves the page is really simple. Please keep in mind that beginners edit the Data pages manually and can easily make mistakes. The error message "Syntax error" is not very informative.

Bhsd subscribed.

Since JSON syntax highlighting is now using CodeMirror on WMF sites, this task is also relevant to CodeMirror.