From:             steven dot mccoy at miru dot hk
Operating system: Ubuntu 7.04
PHP version:      5.2.4RC1
PHP Bug Type:     Class/Object related
Bug description:  stdClass could not be converted to string

Description:
------------
This might be related to bug 41221, upgrading from PHP 5.1.6-1 (Debian) to
5.2.1 (Ubuntu) created a regression in handling output of JSON decoding.

Does this mean that I can only use arrays ( json_decode($json, true) ),
and have to update all code appropriately?

Reproduce code:
---------------
<?php
$array = array(
                "first" => array(array("second" => 2), "two", "three"),
                );
$json = json_encode($array);
$obj = json_decode($json);
var_dump(array_diff($array,$obj->first));
?>


Expected result:
----------------
array(1) {
  ["first"]=>
  array(3) {
    [0]=>
    array(1) {
      ["second"]=>
      int(2)
    }
    [1]=>
    string(3) "two"
    [2]=>
    string(5) "three"
  }
}


Actual result:
--------------
Catchable fatal error: Object of class stdClass could not be converted to
string in /tmp/- on line 7


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

Reply via email to