leaves note

write by a programer

 

json_decode使用时出现Null

可用json_last_error()返回最后发生的错误

json字符串需要注意特殊符号的处理常见的是换行

windows:"\r\n";
linux:"\n";
max:"\r";



返回一个整型(integer),这个值会是以下的常量之一:



JSON 错误码
常量含义可用性
JSON_ERROR_NONE没有错误发生1
JSON_ERROR_DEPTH到达了最大堆栈深度2
JSON_ERROR_STATE_MISMATCH无效或异常的 JSON3
JSON_ERROR_CTRL_CHAR控制字符错误,可能是编码不对4
JSON_ERROR_SYNTAX语法错误5
JSON_ERROR_UTF8异常的 UTF-8 字符,也许是因为不正确的编码。PHP 5.3.3
JSON_ERROR_RECURSIONOne or more recursive references in the value to be encodedPHP 5.5.0
JSON_ERROR_INF_OR_NANOne or more NAN or INF values in the value to be encodedPHP 5.5.0
JSON_ERROR_UNSUPPORTED_TYPEA value of a type that cannot be encoded was givenPHP 5.5.0