json-parse-default
Version:
Parse JSON with default value
51 lines (28 loc) • 897 B
Markdown
> Parse JSON with default value
```
$ npm install json-parse-default
```
```js
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter
) for more.
Type: `object`
When there is exception, this value will be return
Type: `Function`
error callback function
---