<commit_before># JSON5 – Modern JSON

JSON isn't the friendliest to write and maintain by hand. Keys need to be
quoted; objects and arrays can't have trailing commas; comments aren't
supported — even though none of these is the case with regular JavaScript
today.

Restricting JSON to such a strict subset of "JavaScript object notation" made
sense for making it a great data-exchange format, but JSON's usage has
expanded [beyond][ex1] [machine-to-machine][ex2] [communication][ex3].

[ex1]: http://plovr.com/docs.html
[ex2]: http://npmjs.org/doc/json.html
[ex3]: http://code.google.com/p/fuzztester/wiki/JSONFileFormat

**JSON5 is a proposed extension to JSON** that brings ES5 enhancements to its
syntax. It remains a **strict subset of JavaScript**, adds **no new data
types**, and is a **strict superset of existing JSON**.

JSON5 is not an official successor to JSON, and existing JSON parsers may not
understand these new features. It's thus recommended that files use a new
extension like `.json5` to be explicit. *[TODO: New MIME type too?]*

This module provides a JavaScript implementation that works on all modern JS
engines (even IE6). Its parser is based directly off of Douglas Crockford's
eval-free [json_parse.js][], making it both secure and robust. Give it a try!

## Features

These are the new features of JSON5's syntax. All of these are optional, and
all of these are part of ES5 JavaScript.

- Object keys don't need to be quoted if they're valid [identifiers](
  https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Variables). Yes, even reserved keywords are valid unquoted keys in ES5 [[§11.1.5](http://es5.github.com/#x11.1.5), [§7.6](http://es5.github.com/#x7.6)].
  *[TODO: Unicode characters and escape sequences aren't yet supported in this implementation.]*

- Strings can be single-quoted.

- Strings can be split across multiple lines; just prefix each newline with a
  backslash. [ES5 [§7.8.4](http://es5.github.com/#x7.8.4)]

- Objects and arrays can have trailing commas.

- Both inline (single-line) and block (multi-line) comments are allowed.

- Numbers can be hexadecimal (base 16).

## Example

```js
{
    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,
       
    finally: 'a trailing comma',
    oh: [
        "we shouldn't forget",
        'arrays can have',
        'trailing commas too',
    ],
}
```<commit_msg>Add leading decimal mention to readme.<commit_after># JSON5 – Modern JSON

JSON isn't the friendliest to write and maintain by hand. Keys need to be
quoted; objects and arrays can't have trailing commas; comments aren't
supported — even though none of these is the case with regular JavaScript
today.

Restricting JSON to such a strict subset of "JavaScript object notation" made
sense for making it a great data-exchange format, but JSON's usage has
expanded [beyond][ex1] [machine-to-machine][ex2] [communication][ex3].

[ex1]: http://plovr.com/docs.html
[ex2]: http://npmjs.org/doc/json.html
[ex3]: http://code.google.com/p/fuzztester/wiki/JSONFileFormat

**JSON5 is a proposed extension to JSON** that brings ES5 enhancements to its
syntax. It remains a **strict subset of JavaScript**, adds **no new data
types**, and is a **strict superset of existing JSON**.

JSON5 is not an official successor to JSON, and existing JSON parsers may not
understand these new features. It's thus recommended that files use a new
extension like `.json5` to be explicit. *[TODO: New MIME type too?]*

This module provides a JavaScript implementation that works on all modern JS
engines (even IE6). Its parser is based directly off of D<NAME>'s
eval-free [json_parse.js][], making it both secure and robust. Give it a try!

## Features

These are the new features of JSON5's syntax. All of these are optional, and
all of these are part of ES5 JavaScript.

- Object keys don't need to be quoted if they're valid [identifiers](
  https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Variables). Yes, even reserved keywords are valid unquoted keys in ES5 [[§11.1.5](http://es5.github.com/#x11.1.5), [§7.6](http://es5.github.com/#x7.6)].
  *[TODO: Unicode characters and escape sequences aren't yet supported in this implementation.]*

- Strings can be single-quoted.

- Strings can be split across multiple lines; just prefix each newline with a
  backslash. [ES5 [§7.8.4](http://es5.github.com/#x7.8.4)]

- Objects and arrays can have trailing commas.

- Both inline (single-line) and block (multi-line) comments are allowed.

- Numbers can be hexadecimal (base 16), and they can also begin with a leading
  decimal (e.g. `.5`).

## Example

```js
{
    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,
       
    finally: 'a trailing comma',
    oh: [
        "we shouldn't forget",
        'arrays can have',
        'trailing commas too',
    ],
}
```
{'fraction_non_alphanumeric': 0.10401216961399505, 'fraction_numerical': 0.016162768587183875, 'mean_word_length': 3.630281690140845, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1901419', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1540, 'n_words': 679}