From:             
Operating system: linux
PHP version:      5.2.13
Package:          JSON related
Bug Type:         Bug
Bug description:numeric string key escaped in type change

Description:
------------
php treat numeric string key as interge,



bug sometimes there is some exception.



for example:

  while change a std object to array, numeric string key doesn't cast to
number 

Test script:
---------------
<?php

$data = array(

    123 => 'laruence',

    "03"=> 'baidu',

);



$value = json_encode($data);

$obj   = json_decode($value);

$arr   = (array)$obj;

var_dump($arr);

?>

Expected result:
----------------
array(2) {

  [123]=>

  string(8) "laruence"

  ["03"]=>

  string(5) "baidu"

}



Actual result:
--------------
array(2) {

  ["123"]=>

  string(8) "laruence"

  ["03"]=>

  string(5) "baidu"

}



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

Reply via email to