https://github.com/davidbernal/async-json-parser
Async JSON parser (parse & stringify)
https://github.com/davidbernal/async-json-parser
async json parser
Last synced: about 2 months ago
JSON representation
Async JSON parser (parse & stringify)
- Host: GitHub
- URL: https://github.com/davidbernal/async-json-parser
- Owner: DavidBernal
- Created: 2018-12-09T22:06:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-10T09:59:44.000Z (over 7 years ago)
- Last Synced: 2024-12-14T11:43:08.738Z (over 1 year ago)
- Topics: async, json, parser
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# async-json-parser
Real Async JSON parser (parse & stringify). Without dependencies.
## Example
#### Promises
```
const asyncJson = require('./index.js');
const obj = {hola: "mundo"};
const str = '{"hola":"mundo"}';
const log = x => console.log(x) || x;
const type = x => log(typeof x);
asyncJson.stringify(obj).then(log).then(type);
asyncJson.parse(str).then(log).then(type);
```
#### Async/await
```
const asyncJson = require('./index.js');
const obj = {hola: "mundo"};
const str = '{"hola":"mundo"}';
const log = x => console.log(x) || x;
const type = x => log(typeof x);
async function main(){
const s = await asyncJson.stringify(obj);
log(s) && type(s);
const o = await asyncJson.parse(str);
log(o) && type(o);
}
main();
```