Correctly handle JSON parsing errors