On Sat, Jan 21, 2006 at 02:21:14PM +0100, Christian Stocker wrote: > > AFAIK an object in JSON is just an associative array in PHP, so I don't > see the point here in implementing that in anything else than an > associative array on the PHP side.
Exactly what I was going to say. The one thing I'd like to see change is having JSON "objects" decoded into PHP associative arrays, not PHP objects, as is done in the current PECL implementation. Here's what happens now via PECL JSON: ========= script ========= <?php echo '<pre>'; $enum = array('foo', 'bar'); $assoc = array('f' => 'foo', 'b' => 'bar'); $obj = new c; echo "\nInitial PHP:\n"; print_r($enum); print_r($assoc); print_r($obj); $pecl_enum = json_encode($enum); $pecl_assoc = json_encode($assoc); $pecl_obj = json_encode($obj); echo "\nJSON encoded:\n"; echo $pecl_enum . "\n"; echo $pecl_assoc . "\n"; echo $pecl_obj . "\n"; echo "\nPHP decoded from JSON:\n"; print_r(json_decode($pecl_enum)); print_r(json_decode($pecl_assoc)); print_r(json_decode($pecl_obj)); ?> ========= output ========= Initial PHP: Array ( [0] => foo [1] => bar ) Array ( [f] => foo [b] => bar ) c Object ( [f] => foo [b] => bar ) JSON encoded: ["foo","bar"] {"f":"foo","b":"bar"} {"f":"foo","b":"bar"} PHP decoded from JSON: Array ( [0] => foo [1] => bar ) stdClass Object ( [f] => foo [b] => bar ) stdClass Object ( [f] => foo [b] => bar ) --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php