I have been using a modified version an old FC4 public AMI, which is too good to be deserted with all the software I have installed. For a project, I needed support for JSON. Javascript Object Notation or JSON is a way of passing string representation of Javascript objects to the user-agents. Straight-through serialization of Javascript objects and transmittal of such is much more compact than passing XML and then converting them to Javscript objects.
On the server-side you have to create a string representation of a Javascript object and then return it to the caller. This is very similar to formatting data in XML and then sending the XML back to the requesting clients. JSON takes away the overhead of XML (no parsing, DOM walking etc. instead you get a first-class Javascript object). In PHP you can create a JSON string by passing a PHP variable into an encoder function. In PHP 5.2.0 JSON is natively compiled, it was contributed by Omar Kilani who wrote the php-json extension.
You may skip the rest of the post if you already have PHP 5.2.0. Keep on reading if you have PHP 5.0/5.1 on Fedora Core 4 and want JSON functionality.
Good news is that the php-json has an RPM available in fedora-extras. You don’t need do any thingamagic of installing the RPM by hand. Instead use yum to install it seamlessly from the fedora extras repository
(Assuming that You have su privileges)
Step1. Navigate to the /etc/yum.repos.d directory. Check if you have a file called fedora-extras.repo. This file contains the required information for yum to look up the extras repository
Step 2. If you do not have the file then create the file with the following text:
[extras]
name=Fedora Extras $releasever - $basearch
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/extras/$releasever/$basearch/
mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-extras-$releasever
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
gpgcheck=1
If you have the file then make sure the “enabled” flag is set to 1. Extras are normally disabled.
Step 3. Run a yum search command as “yum search php-json”. If your fedora-extras.repo is set correctly then you will see a matching result as:
php-json.i386 1.1.0-1.fc4 extras
Matched from:
php-json
php-json is an extremely fast PHP C extension for JSON (JavaScript Object
Notation) serialisation.
http://www.aurore.net/projects/php-json/
Step 4. If all looks good, run the install command as yum install php-json. That’s it. Have fun with JSON. Read the PHP Manual for usage.