Skip to content

An extention of JSON that supports Next gen features.

License

Notifications You must be signed in to change notification settings

EskelCz/jsonext-esm

 
 

Repository files navigation

JSONext ESM

An extention of JSON that supports Next gen features.

Usage

npm install --save "git+https://github.com/EskelCz/jsonext-esm.git"
import JSONext from 'jsonext-esm'

API

The JSONext API is compatible with the JSON API.

JSONext.parse(text [, reviver])

Parses JSONext text into an ECMAScript value.

JSONext.stringify(value [, replacer [, space]])

Returns a string in JSONext format representing an ECMAScript value.

Current features

JSON5 syntax

{
    // 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',],
    "backward compatible": "with JSON",
}

Infinity and NaN are supported for backward compatibility, but they are deprecated and produce warnings.

Unicode property names

Including unicode escapes. The following documents are equivalent.

{ ùńîċõďë: '¡ celebridad internacional !' }
{ \u00f9\u0144\u00ee\u010b\u00f5\u010f\u00eb: "¡ celebridad internacional !" }

Unicode code point escapes in strings

{ surrogatePairs: '\u{20BB7}' }

Hex escapes in strings

{ hexEscapes: 'No \x65\x73\x63\x61\x70\x65 from reality' }

Template literals without substitutions

{ templates: `Jane said, "It's great!"` }

The following document is invalid.

{ invalidTemplate: `Jane said, "${message}"` }

About

An extention of JSON that supports Next gen features.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%