From:
Operating system: linux
PHP version: 5.3.3
Package: JSON related
Bug Type: Bug
Bug description:json_decode don't make good object
Description:
------------
php > echo $e
php > ;
{"a":1,"b":2}
php > $f = json_decode($e);
php > var_dump($f);
object(stdClass)#2 (2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
php > $g=(array)$f;
php > echo $f['a'];
PHP Fatal error: Cannot use object of type stdClass as array in php shell
code on line 1
Expected result:
----------------
php > $a=array('a'=>1,'b'=>2);
php > $b = (object)$a;
php > $c = (array)$b;
php > var_dump($a);
array(2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
php > echo $c['a'];
1
Actual result:
--------------
PHP Fatal error: Cannot use object of type stdClass as array in php shell
code on line 1
--
Edit bug report at http://bugs.php.net/bug.php?id=52904&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52904&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52904&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52904&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52904&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52904&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52904&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52904&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52904&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52904&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52904&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52904&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52904&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52904&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52904&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52904&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52904&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52904&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52904&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52904&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52904&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52904&r=mysqlcfg