json7
v0.2.0
Published
A better alternative of JSON
Downloads
4
Readme
json7
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