From:             
Operating system: 
PHP version:      5.3.3
Package:          Arrays related
Bug Type:         Bug
Bug description:JSON decoded arrays have broken integer keys

Description:
------------
JSON decoded arrays have their integer keys broken. They are present in the
array 

but they can be neither accessed nor found through array_key_exists.

Test script:
---------------
$obj = json_decode ('{ "3" : "4", "text" : "5" }');

var_dump ($obj);

$arr = (array)$obj;

var_dump ($arr);

var_dump ($arr[3]);

var_dump ($arr["text"]);

var_dump (array_key_exists (3, $arr));

var_dump (array_key_exists ("text", $arr));



Expected result:
----------------
object(stdClass)#10 (2) { ["3"]=> string(1) "4" ["text"]=> string(1) "5" }

array(2) { ["3"]=> string(1) "4" ["text"]=> string(1) "5" }

string(1) "4"

string(1) "5"

bool(true)

bool(true)



Actual result:
--------------
object(stdClass)#10 (2) { ["3"]=> string(1) "4" ["text"]=> string(1) "5" }

array(2) { ["3"]=> string(1) "4" ["text"]=> string(1) "5" }

NULL

string(1) "5"

bool(false)

bool(true)



-- 
Edit bug report at http://bugs.php.net/bug.php?id=53130&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53130&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53130&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53130&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53130&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53130&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53130&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53130&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53130&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53130&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53130&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53130&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53130&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53130&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53130&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53130&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53130&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53130&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53130&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53130&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53130&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53130&r=mysqlcfg

Reply via email to