safely-parse-json
v0.1.0
Published
Safely parse json
Downloads
2,951
Readme
Parse JSON safely
const safe = require('safely-parse-json');
const value = '{ "one": "one" }';
const result = safe(value, options); // value parsed
Options are,
checkString
: iftrue
will assume error ifvalue
is not string [default:true
]returnError
: iftrue
will also return error, and result will be of from{ value, error }
[default:false
]nullOnError
: iftrue
will not return the original value on error, will return null instead [default:false
]