Repository
Current version released
4 years ago
Dependencies
skypack.dev
json5
Versions
Deno JSON5
Example
main.ts
import JSON5 from "https://deno.land/x/json5";
const data = `{
// comments
unquoted: 'and you can quote me on that',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \
No \\n's!",
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
trailingComma: 'in objects', andIn: ['arrays',
],
"backwardsCompatible": "with JSON",
}`;
console.log(JSON5.parse(data));
/*
{
unquoted: "and you can quote me on that",
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! No \\n's!",
hexadecimal: 912559,
leadingDecimalPoint: 0.8675309,
andTrailing: 8675309,
positiveSign: 1,
trailingComma: "in objects",
andIn: [ "arrays" ],
backwardsCompatible: "with JSON"
}
*/
Methods
JSON5.stringify
JSON5.parse
JSON5.require
JSON5.requireAsync