get-json-val
Version:
At the same time, it is a function to judge whether it is a JSON string and the result of parsing the JSON string.
22 lines (18 loc) • 495 B
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var getJSONVal = function getJSONVal(val) {
if (!val || typeof val !== 'string') {
return [new Error('value must be a string'), null];
}
var result = null;
var error = null;
try {
result = JSON.parse(val);
} catch (err) {
error = err;
}
return [error, result];
};
exports["default"] = getJSONVal;
exports.getJSONVal = getJSONVal;
//# sourceMappingURL=get-json-val.cjs.development.js.map
;