mirror of
https://github.com/php/php-src.git
synced 2026-04-25 00:48:25 +02:00
Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric string properties)
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
@@ -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}"
|
||||
Reference in New Issue
Block a user