Unfortunately a lot of Linux distributions are still shipping with PHP 5.1.x.
jsonwrapper implements the json_encode function if it is missing, and leaves it alone if it is already present. So it is nicely future-compatible.
At the top of your code and you're ready to go. Of course, jsonwrapper.php must be in the same folder. If not, adjust the require command.
json_encode exampleJust to give you a sense of the possibilities:
$data = array(
array('name' => 'Jane', 'age' => 35),
array('name' => 'Steve', 'age' => 37)
var data = <?php echo json_encode($data) ?>;