isJsons js code example
Example 1: javascript check if string is json parsable
var isJsonParsable = string => {
try {
JSON.parse(string);
} catch (e) {
return false;
}
return true;
}
Example 2: check if the data can be parsed javascript
function isJson(str) {
try {
return JSON.parse(str);
} catch (e) {
return false;
}
}