Trailing comma in JSON

A trailing comma is a comma after the last item in an object or list. JavaScript and Python accept one, so it's easy to leave behind when you delete or reorder lines. JSON doesn't. In the JSON standard (RFC 8259), a comma goes only between two items, so a parser that finds } or ] right after a comma stops with an error.

In Chrome and Node.js, JSON.parse says: Expected double-quoted property name in JSON

Broken
{
  "name": "Ada Lovelace",
  "tags": ["math", "poetry"],
}
Fixed
{
  "name": "Ada Lovelace",
  "tags": ["math", "poetry"]
}

Fix it by hand

Delete the comma right before each closing } or ].

Open this example in j2n