https://github.com/mastilver/json7
https://github.com/mastilver/json7
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mastilver/json7
- Owner: mastilver
- License: mit
- Created: 2016-08-08T19:14:08.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-12-23T13:00:40.000Z (over 9 years ago)
- Last Synced: 2025-02-03T09:04:15.019Z (over 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# json7 [](https://travis-ci.org/mastilver/json7) [](https://coveralls.io/github/mastilver/json7?branch=master)
> A better alternative of JSON
## Features
- is JSON compatible
- handle Dates
## Install
```
$ npm install --save json7
```
## Usage
```js
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](http://mastilver.com)