From: Ilia Alshanetsky Date: Mon, 17 Oct 2011 23:51:25 +0000 (+0000) Subject: Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric... X-Git-Tag: php-5.3.9RC1~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=199b52c1d47ab209da56725c2dd12c308d453ca9;p=php Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric string properties) --- diff --git a/ext/json/json.c b/ext/json/json.c index 4e8fd759d4..62d20caadf 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -238,7 +238,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) need_comma = 1; } - json_escape_string(buf, key, key_len - 1, options TSRMLS_CC); + json_escape_string(buf, key, key_len - 1, options & ~PHP_JSON_NUMERIC_CHECK TSRMLS_CC); smart_str_appendc(buf, ':'); php_json_encode(buf, *data, options TSRMLS_CC); diff --git a/ext/json/tests/bug55543.phpt b/ext/json/tests/bug55543.phpt new file mode 100644 index 0000000000..8657fe7767 --- /dev/null +++ b/ext/json/tests/bug55543.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #55543 (json_encode() with JSON_NUMERIC_CHECK & numeric string properties) +--SKIPIF-- + +--FILE-- +{"1"} = "5"; + +var_dump(json_encode($a, JSON_NUMERIC_CHECK)); +?> +--EXPECT-- +string(7) "{"1":5}"