NYCPHP Meetup

NYPHP.org

[nycphp-talk] Anybody using JSON parser?

Mark Armendariz lists at enobrev.com
Fri Apr 13 18:01:05 EDT 2007


> Kenneth Downs wrote:
> > JSON strikes me as a worthy candidate.  Is anybody using it on the 
> > server-side with enough confidence to answer this question:  Can I 
> > type a file of JSON stuff by hand and convert it easily 
> into a nested 
> > associative array?

I don't see why not.  JSON is just a standard javascript object, so
hand-typing is pretty simple and decoding into an array with the json
extension is as simple as
$aPhpData = json_decode($sJsonData);

> 
> The parser I'm using is this file: 
> http://mike.teczno.com/JSON/JSON.phps, which is a part of the 
> PEAR proposal for JSON 
> (<http://pear.php.net/pepr/pepr-proposal-show.php?id=198>).
>
> - Allen

I highly recommend using the json extension if you can (comes standard with
php5.2).  The speed difference over using a script is astounding.  I use it
on all my projects (ajaxified cms) without issue.

If you're pre-php5.2...

Linux: http://pecl.php.net/package/json
Win32: http://pecl4win.php.net/ext.php/php_json.dll

Mark




More information about the talk mailing list