Hello,
I've put together a new JSON readers gem called jasony [1]. The
first next generation JSON parser / reader included is `HANSON.parse`
for the JSON for Humans (HanSON) format by Tim Jansen et al.
Using HanSON you can use comments, unquoted keys, multi-line
strings, single-quoted strings, trailing commas, and more. Example:
{
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
]
}
Use `HANSON.convert` to convert HanSON text to ye old' JSON text:
``` json
\{
"listName": "Sesame Street Monsters",
"content": \[
\{ "name": "Cookie Monster",
"background": "Cookie Monster used to be a\\n \.\.\. to eat
\\"healthy\\" food\."
\},
\{ "name": "Herry Monster",
"background": "Herry Monster is a furry blue monster with a
purple nose\.\\n \.\.\. today\."
\}
\]
\}
Note: \`HANSON\.parse\` is the same as \`JSON\.parse\(
HANSON\.convert\(text\)\)\`, that is, HanSON works like a "pre\-processor"
for JSON\.
If you have a favorite "human" JSON format / flavor, let us know\.
Anything missing in HanSON? Do you know any other "human" JSON reader
gems for ruby?
Questions, comments welcome\. Cheers\.
PS: Trivia: Why jasony? The jason gem was already take and jasony is
another "human" name like jason\.
\[1\] https://github.com/datatxt/jasony