1var isJsonParsable = string => {
2 try {
3 JSON.parse(string);
4 } catch (e) {
5 return false;
6 }
7 return true;
8}
1function IsJsonString(str) {
2 try {
3 JSON.parse(str);
4 } catch (e) {
5 return false;
6 }
7 return true;
8}
1if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@').
2replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
3replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
4
5 //the json is ok
6
7}else{
8
9 //the json is not ok
10
11}
12