[dev] Converting stdClass object trees to arrays?

Adam Tauno Williams awilliam at whitemice.org
Mon Apr 25 18:13:24 UTC 2011


I'm updating our Auth and Group providers for the latest Horde release.
These communicate with our backend server using JSON-RPC 1.1.  So I'm
using the Horde_Rpc_Jsonrpc::request class/method.  That part is working
very well [switching from XML-RPC which we used previously].  

In $response->result is the results of the JSON-RPC call. But these are
stdClass object trees, not 'arrays'.  So in some pages I get errors like
-

PHP Fatal error:  Cannot use object of type stdClass as array
in /srv/www/htdocs/horde/templates/admin/groups/edit.inc on line 7

Is the a standard / horde-ish way to convert the deserialized responses
to arrays?

Changing the json_decode in Serialize.php to ($data, true) from just
($data) fixes the issue but obviously that is not correct.



More information about the dev mailing list