Just updated to saucy 13.10 and json_encode is missing from the bundled php. json doesn't appear in the phpinfo() output and i'm getting this error in my app:

PHP Fatal error:  Call to undefined function json_encode()

Anyone else experiencing this or know the fix?


Install php5-json:

sudo apt-get install php5-json

This used to be provided by php5-common but that has changed in Saucy. No idea why and seems like a silly thing to do but it's very simple to fix.

After the installation, make sure to also restart the Apache2 server:

sudo service apache2 restart
  • 6
    thank you. I found this explanation...funny stuff: iteration99.com/2013/php-json-removed-from-php-5-5 – Chris DaMour Oct 18 '13 at 22:58
  • 2
    Oh god, it's that?! I've read about that nonsense ages ago but never dreamed anybody would feel that it was legally contrary to the PHP license. What a waste of time. – Oli Oct 18 '13 at 23:08
  • 1
    @AlexButum It's still on iteration99.com - it's just not available at the moment. I'd guess it's a static site (eg Jekyll) that hasn't been rebuilt properly. – Oli Dec 20 '13 at 14:03

When you install this package, if you don't see php5-fpm restart post install, don't forget to do the following:

sudo service php5-fpm restart
  • Dude, thank U very much - only because Your answer I can use php-json lib, even after restart/reload nginx didn`t load this lib via fpm. Thx a lot. – Arthur Kushman Jan 28 '14 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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