Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am developing on a server that I don't really have all that control over... I just started working for a Kiosk company about 3 months ago. I am used to developing on my localhost (MAMP) and porting it to my hosting company.

I recently wrote a script that takes advantage of json_decode() and it appears the server I am working on does not support this method...

Fatal error: Call to undefined function json_decode() in /var/www/html/scripts/generate_excel.php on line 25

I looked in phpinfo() and on my localhost it has "json support" whereas on this server there is no mention of json in the phpinfo(). The php versions are slightly different...

5.1.6 (json not working) Vs. 5.2.10 (json working)

Was json support added between those versions?

What do I need to get json_decode()/json_encode() working on this server @ work?

Not all that good at this kind of stuff, I try to stay away from configuring anything and just stick to the code when I can...

EDIT:

Now I am having trouble with phpize. Honestly, not sure what phpize actually IS...

Anyways...

[root@rm-003-33 html]# pecl install json
WARNING: channel "pear.php.net" has updated its protocols, use "pecl channel-update pear.php.net" to update
downloading json-1.2.1.tgz ...
Starting to download json-1.2.1.tgz (17,780 bytes)
......done: 17,780 bytes
11 source files, building
running: phpize
sh: phpize: command not found
ERROR: `phpize' failed

Can't figure out how to get phpize to work

Thanks

share|improve this question
    
PECL json was added to 5.2 pecl.php.net/package/json –  Andy Feb 18 '10 at 16:24
add comment

2 Answers 2

up vote 1 down vote accepted

You can install the JSON library for older versions using Pecl or write a wrapper for any of the free libraries and do a simple check like this:

if(!function_exists('json_decode')){
   function json_decode($str){
      // ADD THE LIBRARY CODE FOR DECODE EHRE
   }
}
if(!function_exists('json_encode')){
   function json_encode($obj){
      // ADD THE LIBRARY CODE FOR ENCODE HERE
   }
}
share|improve this answer
    
You can get a list of free libraries here json.org –  Erik Giberti Feb 18 '10 at 15:53
add comment

You have to add gcc-c++ to your system first.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.