JSON inside JavaScript or Python code

Code that builds JSON isn't JSON yet. A line like const user = {...};, JSON.stringify({...}) or json.dumps({...}) wraps the data in a variable or a function call, and the object inside usually follows JavaScript or Python rules: keys without quotes, single quotes, trailing commas. A JSON parser stops at the first word of the code.

In Chrome and Node.js, JSON.parse says: Unexpected token 'c'

Broken
const user = {
  name: 'Ada Lovelace',
  born: 1815,
};
Fixed
{
  "name": "Ada Lovelace",
  "born": 1815
}

Fix it by hand

Copy only the object or list, then quote the keys, switch to double quotes and remove trailing commas.

Open this example in j2n