Edit report at https://bugs.php.net/bug.php?id=55354&edit=1

 ID:                 55354
 Updated by:         [email protected]
 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

Reply via email to