Update isValidJSON.md
This commit is contained in:
@ -8,7 +8,9 @@ Use `JSON.parse()` and a `try... catch` block to check if the provided argument
|
|||||||
const isValidJSON = obj => {
|
const isValidJSON = obj => {
|
||||||
try {
|
try {
|
||||||
JSON.parse(obj);
|
JSON.parse(obj);
|
||||||
|
if (o && typeof o === "object") {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user