npm install graceful-json-parse- jsonString: The string to parse as JSON.
- options(optional)
- options.reviver: If a function, this prescribes how the value originally produced by parsing is transformed, before being returned. more info about this param in here
object {error, data}
- error: should be an Error object in case of error or undefined in case of success
- data: should be the object corresponding to the given JSON text or undefined in case of error
const jsonParse = require("graceful-json-parse");
const result = jsonParse("{}");The parameters and return value is the same as above.
const jsonParse = require("graceful-json-parse/tuple");
const [error, data] = jsonParse("{}");The parameters and return value is the same as above.
const jsonParse = require("graceful-json-parse/callback");
jsonParse("{}", function (error, data) {
// your code
});