//if you happen to have php 5.2.0 or higher you can use the standard json_encode() / json_decode() functions that are //way faster (coded in c, like 100 - 200 times faster) //if you want to keep it portable in case, then try something like this: if (!function_exists('json_encode')){ //now its portable to php ver. < 5.2.0 where you would otherwise have to install the php-json c-extension first include('JSON.php'); $json = new Services_JSON(); function json_encode($value){ global $json; return $json->encode($value); } function json_decode($value){ global $json; return $json->decode($value); } } // then just use the standard functions json_encode() / json_decode()