diginext-utils
Version:
README.md
32 lines (31 loc) • 746 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isJSON = void 0;
/**
* Check if the object or string is in JSON format
*/
const isJSON = (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.isJSON = isJSON;
const Checker = { isJSON: exports.isJSON };
exports.default = Checker;