Bug #55354 [Opn->Asn]: Incorrect typecasting of keys in json_encode w/ JSON_NUMERIC_CHECK set
| From: | felipe@php.net | Date: | Wed, 03 Aug 2011 23:21:14 +0000 |
| Subject: | Bug #55354 [Opn->Asn]: 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-162393@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: felipe@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: Open
+Status: Assigned
Type: Bug
Package: JSON related
Operating System: Windows 7
PHP Version: 5.3.6
-Assigned To:
+Assigned To: iliaa
Block user comment: N
Private report: N
New Comment:
The JSON_NUMERIC_CHECK is supposed to work in the value, not the key.
Is it right, @Ilia?
Previous Comments:
------------------------------------------------------------------------
[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