timjansen/hanson: JSON for Humans - with unquoted identifiers, multi-line strings and comments @GitHub
HanSON is an extension of JSON that fixes its shortcomings with a few simple additions to the JSON spec:
- quotes for strings are optional if they follow JavaScript identifier rules.
- you can alternatively use backticks, as in ES6's template string literal, as quotes for strings. A backtick-quoted string may span several lines and you are not required to escape regular quote characters, only backticks. Backslashes still need to be escaped, and all other backslash-escape sequences work like in regular JSON.
- for single-line strings, single quotes (
''
) are supported in addition to double quotes (""
) - you can use JavaScript comments, both single line (
//
) and multi-line comments (/* */
), in all places where JSON allows whitespace. - Commas after the last list element or object property will be ignored.
Example HanSON
{
listName: "Sesame Street Monsters", // note that listName needs no quotes
content: [
{
name: "Cookie Monster",
/* Note the template quotes and unescaped regular quotes in the next string */
background: `Cookie Monster used to be a
monster that ate everything, especially cookies.
These days he is forced to eat "healthy" food.`
}, {
// You can single-quote strings too:
name: 'Herry Monster',
background: `Herry Monster is a furry blue monster with a purple nose.
He's mostly retired today.`
}, // don't worry, the trailing comma will be ignored
]
}
used here: gfxfundamentals/webgpufundamentals @GitHub
and here: gfxfundamentals/webgl-fundamentals: WebGL lessons that start with the basics