Skip to content

Instantly share code, notes, and snippets.

@jyc
Created July 4, 2014 17:22
Show Gist options
  • Select an option

  • Save jyc/5150a01ec7a655c656d1 to your computer and use it in GitHub Desktop.

Select an option

Save jyc/5150a01ec7a655c656d1 to your computer and use it in GitHub Desktop.
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment