@iridium/async-json-parser

1.0.0 • Public • Published

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();

Readme

Keywords

none

Package Sidebar

Install

npm i @iridium/async-json-parser

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.1 kB

Total Files

5

Last publish

Collaborators

  • davidbernal