4

I installed PHP Version 5.5.1-2 on Ubuntu 12.04 and JSON was not bundled with it (as far as I can tell).

I've read that I will have to reinstall php using the --enable-json or --with-json option.
So my questions are:

How can I verify JSON is not installed?

If not, do I reinstall php like this: apt-get install php --with-json (do I include --enable-json)?

Will my current settings be lost if I reinstall php?

Thanks

2
  • json support is there by default you should be able to use json_encode and json_decode with no problem have you tried to use them? Commented Aug 28, 2013 at 16:19
  • Unfortunately it is not there, don't know why?? Commented Aug 28, 2013 at 16:34

4 Answers 4

17

If you haven't already installed it:

sudo apt-get install php5-json

(more info: http://iteration99.com/2013/php-json-removed-from-php-5-5/ )

Shouldn't overwrite any other settings.

Sign up to request clarification or add additional context in comments.

Comments

2

JSON is enabled by default on ubuntu

#php -i | grep -i json
json
json support => enabled
json version => 1.2.1

2 Comments

php -i | grep -i json returns nothing at all
Actually just try php -i and see if you get anything. You may not have php5-cli installed
1

Test if json_encode (or any of the other JSON functions) exist.

Either call it and observe an error or use function_exists("json_encode").

4 Comments

Response from call:Fatal error: Call to undefined function json_decode()
JSON is disabled then.
If I try to enable using extension=json I get the following: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/json' - /usr/lib/php5/20121212/json: cannot open shared object file: No such file or directory in Unknown on line 0
I guess you're missing the extension file. See if you can find it in the source installer or just reinstall PHP.
0

Ubuntu 12.04 doesn't support

sudo apt-get install php5-json

directly. the installer change it automatically to

sudo apt-get install php5-common

My recommandation should be to use sudo apt-get install php5-common instead of sudo apt-get install php5-json because sudo apt-get install php5-common will install also automatically all other dependencies for you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.