Was PHP JSON removed from PHP 5.5?

Original author: Iteration 99
  • Transfer
Perhaps some of you, upgrading php to version 5.5 on your Linux machines, have found a good part of their applications to be down because of a fatal error similar to this:

PHP Fatal error: Call to undefined function json_encode()

Why did this happen, read the free translation of the article “Has PHP JSON been removed in PHP 5.5?”,
Under the cat.

What's happening?



Crockford ( Douglas Crockford ) JSON - a widely used data exchange format, found itself in a license conflict with PHP on Linux distributions due to a line in the first license agreement, which states:

“The Software shall be used for Good, not Evil.”

In this, the JSON license does not converge with freedom number zero from the Free Software Foundation:
“The freedom to run the program for any purpose.”
(the program can be freely used for any purpose)


Although this may seem insignificant, the author of json.org politely refuses to amend the license. The answer was to remove the standard PHP JSON extension in PHP 5.5rc2 in Debian, Fedora, and other distributions.

Until the package manager of your Linux distribution starts providing the json extension as a package, the json functions may not be available. Any code using these standard functions will result in errors:

PHP Fatal error: Call to undefined function json_encode()
PHP Fatal error: Call to undefined function json_decode()

(Translator's note: in ubuntu server 13.10 PHP 5.5.3-1ubuntu2, the JSON extension comes as a separate php5-json package)

The solution for those affected


JSON in PHP will be provided by other extensions in due time and hopefully it will be transparent to the end user, but if you do not want to wait with the update and you are affected by this problem, you can install the PECL JSON-C extension from Remy (jsonc by Remi Collet) which uses the json-c library.

My solution for CentOS 5.9 was to install the PECL JSON-C extension from the Remy repository for YUM:
yum --enablerepo=remi install php-pecl-jsonc


For Debian distributions, a third-party repository from Ondřej may be useful (translator's note: I suppose we are talking about this )

If you installed the extension manually, do not forget to add it to php.ini.

Links:
bugs.php.net/bug.php?id=63520
github.com/remicollet/pecl-json-c

Original article

www.json.org/license.html
www.gnu.org/philosophy/free-sw.html

From translator

The article is dated August 9th and is not quite relevant (for fresh ubuntu, for example, there is a php5-json package). I decided to publish this translation for two reasons:
  1. I want to notify those who are concerned that it is not like mine. Having upgraded my server to Ubuntu 13.10, I spent some time looking for the reasons for the gathering of part of the functional and finding a solution;
  2. The very reason for removing json from php seemed to me quite ... Interesting, if I may say so. And the reason for the removal and the fact of the existence of the above line in the license for json.org;

Also popular now: