diginext-utils
Version:
README.md
32 lines • 749 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValid = void 0;
/**
* Check if the object or string is in JSON format
*/
const isValid = (content) => {
if (typeof content == "object") {
try {
content = JSON.stringify(content);
}
catch (err) {
return false;
}
}
if (typeof content == "string") {
try {
content = JSON.parse(content);
}
catch (err) {
return false;
}
}
if (typeof content != "object") {
return false;
}
return true;
};
exports.isValid = isValid;
const xjson = { isValid: exports.isValid };
exports.default = xjson;
//# sourceMappingURL=json.js.map