Catch JSON parsing in JS