PDA

View Full Version : JSON.php in Alpha versions



tad_scsi
9 Mar 2007, 6:24 AM
As an example..

In the yui-ext libraries, JSON.php was required to run at least one of the examples - Image Chooser

In the ext libraries, in the same example, JSON.php is not called from get-images.php AND the last two lines read as follows:

$o = array('images'=>$images);
echo json_encode($o);

However, the only way I can seem to get the Image Chooser to work in Alpha is by going into get-images.php and adding the require_once and changing the last two lines to this:

$o = array('images'=>$images);
$json = new Services_JSON();
echo $json->encode($o);


Am I missing a point here, is JSON.php no longer required, and if not - why might I be getting unknown function type errors?

Belgabor
9 Mar 2007, 1:11 PM
PHP versions >= 5.2 have built-in json_encode, so JSON.php is no longer needed.

tad_scsi
9 Mar 2007, 2:24 PM
Thanks, that is nice to know - I'm currently running 5.1.2 here. I'll be moving to a virtual private server soon and be able to implement 5.2 everywhere at that time.