Parse JSON with default value
$ npm install json-parse-default
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));
Type: string
Type: Function
Prescribes how the value originally produced by parsing is transformed, before being returned. See JSON.parse
docs for more.
Type: object
When there is exception, this value will be return
Type: Function
error callback function