json-parse-default

1.1.0 • Public • Published

json-parse-default

Parse JSON with default value

Install

$ npm install json-parse-default

Usage

const jsonParse = require('json-prase-default');

const json = '{"enable": true}';

const jsonObj = jsonParse(json, null, {}, null);

const jsonObj = jsonParse(json, null, {}, (e) => console.log(e));

API

jsonParse(string, reviver?, default?, onError?)

string

Type: string

reviver

Type: Function

Prescribes how the value originally produced by parsing is transformed, before being returned. See JSON.parse docs for more.

default

Type: object

When there is exception, this value will be return

onError

Type: Function

error callback function


Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i json-parse-default

      Weekly Downloads

      21

      Version

      1.1.0

      License

      MIT

      Unpacked Size

      3.16 kB

      Total Files

      4

      Last publish

      Collaborators

      • andrei0807