diff options
author | Nikita Popov <nikic@php.net> | 2012-06-23 20:46:27 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2012-06-23 20:51:52 +0200 |
commit | 84fe2cc890e49f40bac7c3ba74b3cfc6dc4cef2f (patch) | |
tree | 4b07a64554232483751acac245a9eb43154d0ecc /ext/json/JSON_parser.h | |
parent | cc90ac54beb7359e5a3210261ce09159bbc43e92 (diff) | |
download | php-git-84fe2cc890e49f40bac7c3ba74b3cfc6dc4cef2f.tar.gz |
Improve json_encode error handling
json_encode() now returns bool(false) for all possible errors, throws the
respective warning and also sets the respective json_last_error() error
code. Three new error codes have been added:
* JSON_ERROR_RECURSION
* JSON_ERROR_INF_OR_NAN
* JSON_ERROR_UNSUPPORTED_TYPE
To get a partial JSON output instead of bool(false) the option
JSON_PARTIAL_OUTPUT_ON_ERROR can be specified. In this case the invalid
segments will be replaced either by null (for recursion, unsupported type
and invalid JSON) or 0 (for Inf and NaN).
The warning for invalid UTF-8 stays intact and is thrown also with
display_errors = On. If this behavior is undesired this can be remedied
later.
Diffstat (limited to 'ext/json/JSON_parser.h')
-rw-r--r-- | ext/json/JSON_parser.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/json/JSON_parser.h b/ext/json/JSON_parser.h index 746190bb35..5037344890 100644 --- a/ext/json/JSON_parser.h +++ b/ext/json/JSON_parser.h @@ -24,7 +24,10 @@ enum error_codes { PHP_JSON_ERROR_STATE_MISMATCH, PHP_JSON_ERROR_CTRL_CHAR, PHP_JSON_ERROR_SYNTAX, - PHP_JSON_ERROR_UTF8 + PHP_JSON_ERROR_UTF8, + PHP_JSON_ERROR_RECURSION, + PHP_JSON_ERROR_INF_OR_NAN, + PHP_JSON_ERROR_UNSUPPORTED_TYPE }; extern JSON_parser new_JSON_parser(int depth); |