19 lines
311 B
JavaScript
19 lines
311 B
JavaScript
module.exports = SafeParse
|
|
|
|
function SafeParse(obj, reviver, callback) {
|
|
if (arguments.length === 2) {
|
|
callback = reviver
|
|
reviver = null
|
|
}
|
|
|
|
var json
|
|
|
|
try {
|
|
json = JSON.parse(obj, reviver)
|
|
} catch (err) {
|
|
return callback(err)
|
|
}
|
|
|
|
callback(null, json)
|
|
}
|