var isJsonParsable = string => {
try {
JSON.parse(string);
} catch (e) {
return false;
}
return true;
}
if (/^[],:{}s]*$/.test(text.replace(/["/bfnrtu]/g, '@').
replace(/"[^"
]*"|true|false|null|-?d+(?:.d*)?(?:[eE][+-]?d+)?/g, ']').
replace(/(?:^|:|,)(?:s*[)+/g, ''))) {
//the json is ok
}else{
//the json is not ok
}