For reasons no will to explain, I’m using joomla 1.5 on PHP 5.1.6 on the year 2012, which is very much like driving a Chevy on F1.
Anyhow, I had hit a few times the problem of using extensions where json was required..
so finally i found this post “The post” with this nice solution..
1. First of all, get this file JSON, from here http://mike.teczno.com/JSON.tar.gz
2. Then put it on the same folder you are going to call it, there has to be a way to include it on the libraries, but this is already to much…
3. Next, include this at the end of the file, if you copy and paste pay attention to quotes” ”
// Future-friendly json_encode
if( !function_exists('json_encode') ) {
function json_encode($data) {
$json = new Services_JSON();
return( $json->encode($data) );
}
}
// Future-friendly json_decode
if( !function_exists('json_decode') ) {
function json_decode($data) {
if ($bool) {
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
} else {
$json = new Services_JSON();
}
return( $json->decode($data) );
}
}
the past code goes at the end fo the JSON.PHP before ?>
Then include the file where you need it
require_once('JSON.php');
Done
Last minute update***
on working on K2 the last try will cause an error, because K2 already calls json
Fatal error: Cannot redeclare class services_json in …
So, add to the k2 json.php file, the same piece of code on step,3, always at the bottom of the file. and then call it like this
require_once(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'JSON.php');
