json7

A better alternative of JSON

Usage no npm install needed!

<script type="module">
  import json7 from 'https://cdn.skypack.dev/json7';
</script>

README

json7 Build Status Coverage Status

A better alternative of JSON

Features

  • is JSON compatible
  • handle Dates

Install

$ npm install --save json7

Usage

import json7 from 'json7';

const a = {
    text: 'test',
    date: new Date(2016, 7, 4),
};
a['obj'] = a;

const json = json7.stringify(a);
const b = json7.parse(json);

console.log(b === b.obj); // => true
console.log(b);
/* => {
    text: 'test',
    date: Thu Aug 04 2016 00:00:00 GMT+0100 (GMT Summer Time),
    obj: {...}
}
*/  

API

json7.stringify(object)

Returns a string representing the inputted object.

object

Type: any

json7.parse(string)

string

Type: String

The json7 representation of an object.

License

MIT © Thomas Sileghem