diff options
-rw-r--r-- | ext/json/json.c | 4 | ||||
-rw-r--r-- | ext/json/php_json.h | 32 |
2 files changed, 20 insertions, 16 deletions
diff --git a/ext/json/json.c b/ext/json/json.c index d120aa9f32..8042f70d23 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -195,7 +195,7 @@ static PHP_FUNCTION(json_encode) zval *parameter; smart_str buf = {0}; zend_long options = 0; - zend_long depth = JSON_PARSER_DEFAULT_DEPTH; + zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", ¶meter, &options, &depth) == FAILURE) { return; @@ -224,7 +224,7 @@ static PHP_FUNCTION(json_decode) char *str; size_t str_len; zend_bool assoc = 0; /* return JS objects as PHP objects by default */ - zend_long depth = JSON_PARSER_DEFAULT_DEPTH; + zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH; zend_long options = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bll", &str, &str_len, &assoc, &depth, &options) == FAILURE) { diff --git a/ext/json/php_json.h b/ext/json/php_json.h index da6eb12cbd..2e0bc1b2ee 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -37,20 +37,6 @@ extern zend_module_entry json_module_entry; #include "TSRM.h" #endif -ZEND_BEGIN_MODULE_GLOBALS(json) - int encoder_depth; - int error_code; - int encode_max_depth; -ZEND_END_MODULE_GLOBALS(json) - -#ifdef ZTS -# define JSON_G(v) TSRMG(json_globals_id, zend_json_globals *, v) -#else -# define JSON_G(v) (json_globals.v) -#endif - -PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC); -PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth TSRMLS_DC); extern PHP_JSON_API zend_class_entry *php_json_serializable_ce; /* error codes */ @@ -83,10 +69,28 @@ typedef enum { #define PHP_JSON_OUTPUT_ARRAY 0 #define PHP_JSON_OUTPUT_OBJECT 1 +/* default depth */ +#define PHP_JSON_PARSER_DEFAULT_DEPTH 512 + +ZEND_BEGIN_MODULE_GLOBALS(json) + int encoder_depth; + int encode_max_depth; + php_json_error_code error_code; +ZEND_END_MODULE_GLOBALS(json) + +#ifdef ZTS +# define JSON_G(v) TSRMG(json_globals_id, zend_json_globals *, v) +#else +# define JSON_G(v) (json_globals.v) +#endif + /* json_decode() options */ #define PHP_JSON_OBJECT_AS_ARRAY (1<<0) #define PHP_JSON_BIGINT_AS_STRING (1<<1) +PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC); +PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth TSRMLS_DC); + static inline void php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, zend_long depth TSRMLS_DC) { php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth TSRMLS_CC); |