angular to check if the string is a valida json or not code example
Example 1: if json valide js
function IsJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
Example 2: javascript json trypass
Uncaught SyntaxError: Unexpected token c in JSON at position 1