noxon
Version:
Better JSON parsing and manipulation in TypeScript.
15 lines (14 loc) • 322 B
JavaScript
const parseJSON = (string) => {
try {
if (typeof string !== "string" || string === null)
throw new Error("Passed argument in parseJSON() is not a string");
const parsed = JSON.parse(string);
return parsed;
} catch (error) {
console.error(error);
return void 0;
}
};
export {
parseJSON
};