From fedora-extras-commits at redhat.com Thu Jun 11 14:45:31 2015 Content-Type: multipart/mixed; boundary="===============5496187023856217744==" MIME-Version: 1.0 From: fedora-extras-commits at redhat.com To: scm-commits at lists.fedoraproject.org Subject: rpms/php-json/FC-4 php-json.html, NONE, 1.1 php-json.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2 Date: Sat, 31 Dec 2005 06:32:08 -0500 Message-ID: <200512311132.jBVBWeph002317@cvs-int.fedora.redhat.com> --===============5496187023856217744== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: ivazquez Update of /cvs/extras/rpms/php-json/FC-4 In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2278/FC-4 Modified Files: .cvsignore sources = Added Files: php-json.html php-json.spec = Log Message: auto-import php-json-1.1.0-1.fc4 on branch FC-4 from php-json-1.1.0-1.fc4.s= rc.rpm --- NEW FILE php-json.html --- omar kilani - projects - php-json


       = ;     3D"omar

home | projects

libical | php-js | php-json | postfix_memcached


       = ;    

php-json

php-json is an extremely fast PHP C extension for JSON (JavaScript Object Notation) serialisati= on. php-json uses a forked version of json-c.

Download

Version 1.1.0 (SRPM, Win32: PHP 4.x, PHP 5.0.x, PHP 5.1.x) - Released 2005-12-04 - Port to Win32.

Version 1.0.8 (SRPM) - Released 2005-12-01 - Changed license to LGPL, modified = build system to allow static compilation into PHP, added strndup check for = json-c.

Version 1.0.7 - Released 2005-09-07 - Fixed issues with negative array keys (= Thanks to Marek Lewczuk for the report,) modified json-c to return a= n error on unquoted object key names instead of going into an infinite loop= .

Version 1.0.6 - Released 2005-08-05 - Fixed issues with exporting private and= protected class members (Thanks to Marek Lewczuk for the report.)

Version 1.0.5 - Released 2005-06-16 - Changed spacing in json-c encoding, add= ed optional assoc (boolean) parameter to json_decode to decode as as= sociative array instead of object (Thanks to James Jones for the pat= ch and Oscar F. Dur=C3=B3n for the discussion), fixed issues with es= caping /.

Version 1.0.3 - Released 2005-06-15 - Fixed json-c string corruption issues u= nder Mac OS X (thanks to Brett Stimmerman for the report) and FreeBS= D (thanks to Robert S Wojciechowski for the report.)

Version 1.0.2 - Released 2005-06-11 - Fixed issues with object reference coun= ts under PHP4. Thanks to James Jones for the report.

Version 1.0.1 - Released 2005-06-10 - Fixed non-linear and mixed type array i= ndex issues, fixed issues with escaping \\, forked json-c and added Unicode= support.

Version 1.0.0 - Released 2005-04-01 - Initial release.

Mailing List

= =
3D"Google Subscribe to php-json
Email:
Browse Archives = at groups.google.com

Documentation

A simple ./configure; make; make install should do the tr= ick. Make sure to add an extension=3Djson.so line to your php.ini/ph= p.d. Note: you need to compile php-json with gcc 3.x and up.

Then, just use json_encode to encode your PHP values into= JSON, and json_decode to decode JSON into a PHP value.

For example:

$output =3D json_encode($val);
echo $output."\n";
        
=

Would produce:

{ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "arr": [ 1, 2, 3,=
 null, 5 ], "float": 1.2345 }
        

While:

$input =3D '{ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "arr"=
: [ 1, 2, 3, null, 5 ], "float": 1.2345 }';
$val =3D json_decode($input);
echo $val->abc."\n";
        

Would produce:

12
        

As of version 1.0.5, json_decode takes an optional= parameter, assoc (boolean), that returns an associative array inste= ad of an object.

A PHP object correlates to a JavaScript object (associative arra= y, i.e., key =3D> value pairs), so the above would be referenced in Java= Script like so:

var obj =3D ...; /* retrieve JSON and eval() it, returning an object */
var result =3D obj["abc"] * obj["float"];
alert("result is " + result);
        

This should display an alert box with the value of result, i.e.,= 14.814.

Performance

Following are some performance metrics for the php-json C extens= ion in comparison to a native PHP implementation of JSON. The C extension i= s 86 times faster than the native PHP implementation in this test. M= ore complex examples generally show the C extension in even better light, w= here a speed increase of 270 times is not uncommon.

Test string is:
{ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "arr": [ 1, 2, 3,=
 null, 5 ], "float": 1.2345 }

Initial C output is:
object(stdClass)#1 (6) refcount(1){
  ["abc"]=3D>
  long(12) refcount(1)
  ["foo"]=3D>
  string(3) "bar" refcount(1)
  ["bool0"]=3D>
  bool(false) refcount(1)
  ["bool1"]=3D>
  bool(true) refcount(1)
  ["arr"]=3D>
  array(5) refcount(1){
    [0]=3D>
    long(1) refcount(1)
    [1]=3D>
    long(2) refcount(1)
    [2]=3D>
    long(3) refcount(1)
    [3]=3D>
    NULL refcount(1)
    [4]=3D>
    long(5) refcount(1)
  }
  ["float"]=3D>
  double(1.2345) refcount(1)
}
Timing 1000 iterations with C
0.027885913848877 seconds elapsed


Initial PHP output is:
object(ObjectFromJSON)#3 (6) refcount(2){
  ["abc"]=3D>
  long(12) refcount(1)
  ["foo"]=3D>
  string(3) "bar" refcount(1)
  ["bool0"]=3D>
  bool(false) refcount(1)
  ["bool1"]=3D>
  bool(true) refcount(1)
  ["arr"]=3D>
  array(5) refcount(1){
    [0]=3D>
    long(1) refcount(1)
    [1]=3D>
    long(2) refcount(1)
    [2]=3D>
    long(3) refcount(1)
    [3]=3D>
    NULL refcount(1)
    [4]=3D>
    long(5) refcount(1)
  }
  ["float"]=3D>
  double(1.2345) refcount(1)
}
Timing 1000 iterations with PHP
2.3223311901093 seconds elapsed


--- NEW FILE php-json.spec --- %define php_extdir %(php-config --extension-dir 2>/dev/null || echo %{_libd= ir}/php4) %{!?php_version:%define php_version %(php-config --version 2>/dev/null || e= cho 4.3.11)} Name: php-json Version: 1.1.0 Release: 1%{?dist} Summary: An extremely fast PHP extension for JSON Group: Development/Languages License: LGPL URL: http://www.aurore.net/projects/php-json/ Source0: http://www.aurore.net/projects/php-json/php-json-ext-%{vers= ion}.tar.bz2 Source1: php-json.html BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} = -n) BuildRequires: php-devel Requires: php =3D %{php_version} %description php-json is an extremely fast PHP C extension for JSON (JavaScript Object Notation) serialisation. %prep %setup -q -n php-json-ext-%{version} install -p -m 0644 %{SOURCE1} . phpize --clean phpize %build %configure make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%{php_extdir} install -p -m 0755 modules/json.so $RPM_BUILD_ROOT%{php_extdir} mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/php.d cat > $RPM_BUILD_ROOT%{_sysconfdir}/php.d/json.ini << EOF ; Enable json extension module extension=3Djson.so EOF %check ||: cat > test.ini << EOF open_basedir=3D safe_mode=3D0 output_buffering=3D0 extension_dir=3D${PWD}/modules extension=3Djson.so EOF php -m -c test.ini 2> /dev/null | grep -q json || { echo "JSON extension not loadable!" exit 1 } %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc php-json.html %config(noreplace) %{_sysconfdir}/php.d/json.ini %{php_extdir}/json.so %changelog * Fri Dec 30 2005 Ignacio Vazquez-Abrams 1.1.0-1 - Initial RPM release Index: .cvsignore =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/extras/rpms/php-json/FC-4/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- .cvsignore 31 Dec 2005 11:31:10 -0000 1.1 +++ .cvsignore 31 Dec 2005 11:32:07 -0000 1.2 @@ -0,0 +1 @@ +php-json-ext-1.1.0.tar.bz2 Index: sources =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/extras/rpms/php-json/FC-4/sources,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- sources 31 Dec 2005 11:31:10 -0000 1.1 +++ sources 31 Dec 2005 11:32:07 -0000 1.2 @@ -0,0 +1 @@ +4a1a41fafabf866784868af59bf30510 php-json-ext-1.1.0.tar.bz2 --===============5496187023856217744==--