write by a programer
json_decode使用时出现Null
可用json_last_error()返回最后发生的错误
json字符串需要注意特殊符号的处理常见的是换行
windows:"\r\n"; linux:"\n"; max:"\r";
返回一个整型(integer),这个值会是以下的常量之一:
常量 | 含义 | 可用性 |
---|---|---|
JSON_ERROR_NONE | 没有错误发生 | 1 |
JSON_ERROR_DEPTH | 到达了最大堆栈深度 | 2 |
JSON_ERROR_STATE_MISMATCH | 无效或异常的 JSON | 3 |
JSON_ERROR_CTRL_CHAR | 控制字符错误,可能是编码不对 | 4 |
JSON_ERROR_SYNTAX | 语法错误 | 5 |
JSON_ERROR_UTF8 | 异常的 UTF-8 字符,也许是因为不正确的编码。 | PHP 5.3.3 |
JSON_ERROR_RECURSION | One or more recursive references in the value to be encoded | PHP 5.5.0 |
JSON_ERROR_INF_OR_NAN | One or more NAN or INF values in the value to be encoded | PHP 5.5.0 |
JSON_ERROR_UNSUPPORTED_TYPE | A value of a type that cannot be encoded was given | PHP 5.5.0 |