. Advertisement .
..3..
. Advertisement .
..4..
I am trying to validate json in javascript but I’ve not found a solution for it yet. Can someone share with me your experience?
Here is our case study:try-catch
handles the unexpected errors that could crop up in a given string of JSON data without causing your program to crash. It can handle missing parameters, faulty syntax, and wrong splitter arguments.
function IsJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
This way to validate json in javascript