I am new to Javascript trying to create a project that uses JSON.parse() function. My code runs successfully however JSON.parse
dint work and didn't return any error on the dev tools console log.
I tried to debug my code with:
console.log("Test log1#######")
console.log(JSON.parse(json));
console.log("Test log2#######")
On the console.log i can only see "Test log1#######"
. but not the "Test log2#######"
which means code fails at line two but without printing any error on Devtools console as it does normally. But I am sure the code is failing due to some JSON validation issue but I can't see the. error anywhere on dev tools.
Please suggest a method to explore the error log of JSON.parse()
thanks
You can do :
try{
JSON.parse(badFormat);
}catch(err){
console.log(err);
}