Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric string properties)

This commit is contained in:
Ilia Alshanetsky 2011-10-17 23:51:25 +00:00
parent 1619ebbec6
commit 199b52c1d4
2 changed files with 14 additions and 1 deletions

View File

@ -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);

View File

@ -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}"