Bug #55354 [Asn->Bgs]: Incorrect typecasting of keys in json_encode w/ JSON_NUMERIC_CHECK set
| From: | iliaa@php.net | Date: | Thu, 04 Aug 2011 13:23:54 +0000 |
| Subject: | Bug #55354 [Asn->Bgs]: Incorrect typecasting of keys in json_encode w/ JSON_NUMERIC_CHECK set | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162409@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55354&edit=1
ID: 55354
Updated by: iliaa@php.net
Reported by: rick dot van dot ravensberg at tribal-im dot com
Summary: Incorrect typecasting of keys in json_encode w/
JSON_NUMERIC_CHECK set
-Status: Assigned
+Status: Bogus
Type: Bug
Package: JSON related
Operating System: Windows 7
PHP Version: 5.3.6
Assigned To: iliaa
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The numeric check only works on values.
Previous Comments:
------------------------------------------------------------------------
[2011-08-03 23:21:14] felipe@php.net
The JSON_NUMERIC_CHECK is supposed to work in the value, not the key.
Is it right, @Ilia?
------------------------------------------------------------------------
[2011-08-03 11:31:11] rick dot van dot ravensberg at tribal-im dot com
Description:
------------
When using json_encode with JSON_NUMERIC_CHECK, json_encode still converts all
array keys to a string, instead of keeping integer keys as integer. However, the
JSON_NUMERIC_CHECK option does work correctly on all the array values.
Test script:
---------------
<?php
$array = array (
1 => "foo",
5 => "bar",
"10" => 50,
);
echo json_encode ($array, JSON_NUMERIC_CHECK);
?>
Expected result:
----------------
{1:"foo",5:"bar","10":50}
Actual result:
--------------
{"1":"foo","5":"bar","10":50}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55354&edit=1