mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric string properties)
This commit is contained in:
parent
1619ebbec6
commit
199b52c1d4
@ -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);
|
||||
|
13
ext/json/tests/bug55543.phpt
Normal file
13
ext/json/tests/bug55543.phpt
Normal 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}"
|
Loading…
Reference in New Issue
Block a user