Skip to content

andrei0807/json-parse-default

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published