Update isValidJSON.md

This commit is contained in:
Rohit Tanwar
2017-12-31 18:38:09 +05:30
committed by GitHub
parent 7b6aad54fa
commit e59829b9ef

View File

@ -8,7 +8,9 @@ Use `JSON.parse()` and a `try... catch` block to check if the provided argument
const isValidJSON = obj => {
try {
JSON.parse(obj);
if (o && typeof o === "object") {
return true;
}
} catch (e) {
return false;
}