diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2011-10-17 23:51:25 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2011-10-17 23:51:25 +0000 |
commit | d4ae4e79db0e898fc74a9a6b7b938b59463a8c7d (patch) | |
tree | af01cb51ea837b81fb45d13c5f1d5384a5ea3fb6 | |
parent | 1f78177e2b148ca502b65a8f22c341260aac627b (diff) | |
download | php-git-d4ae4e79db0e898fc74a9a6b7b938b59463a8c7d.tar.gz |
Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric string properties)
-rw-r--r-- | ext/json/json.c | 2 | ||||
-rw-r--r-- | ext/json/tests/bug55543.phpt | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/ext/json/json.c b/ext/json/json.c index 3c20498aa8..c7759ed740 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -297,7 +297,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) json_pretty_print_indent(buf, options TSRMLS_CC); - 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, ':'); json_pretty_print_char(buf, 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-- +<?php if (!extension_loaded("json")) print "skip"; ?> +--FILE-- +<?php +$a = new stdClass; +$a->{"1"} = "5"; + +var_dump(json_encode($a, JSON_NUMERIC_CHECK)); +?> +--EXPECT-- +string(7) "{"1":5}" |