웹프로그래밍/Javascript
validate JSON (JSON 여부 검사)
jihun202
2020. 7. 8. 10:15
반응형
const isJson = (str: string) => {
try {
const json = JSON.parse(str);
return json && typeof json === 'object';
} catch (e) {
return false;
}
};
반응형