JSON5 – JSON for Humans

JSON5 specification looks like a much more useful JSON, especially for those of us who are still more human than machine.  Here are some of the improvements:

  • Objects and arrays can have trailing commas.
  • Strings can be single-quoted.
  • Strings can have line breaks.
  • Numbers can be signed, begin or end with a decimal point, and also in base 16.
  • Inline and block comments are supported.

Here’s an example:

{
    foo: 'bar',
    while: true,

    this: 'is a \
multi-line string',

    // this is an inline comment
    here: 'is another', // inline comment

    /* this is a block comment
       that continues on another line */

    hex: 0xDEADbeef,
    half: .5,
    delta: +10,
    to: Infinity,   // and beyond!

    finally: 'a trailing comma',
    oh: [
        "we shouldn't forget",
        'arrays can have',
        'trailing commas too',
    ],
}

 

Leave a Comment