RE: [PHP-DEV] json_encode()

From: Date: Mon, 15 Dec 2008 20:55:29 +0000
Subject: RE: [PHP-DEV] json_encode()
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-42270@lists.php.net to get a copy of this message
As is noted in an earlier mail, I would prefer 1 (simply document it in the function description). In my opinion, if somebody then passes a basic type to json_encode he is aware of what he is doing (hopefully). For compatibility with current code and securely escaping strings for javascript it is the best. ----- Uwe Schindler thetaphi@php.net - http://www.php.net NSAPI SAPI developer Bremen, Germany > -----Original Message----- > From: Rasmus Lerdorf [mailto:rasmus@lerdorf.com] > Sent: Monday, December 15, 2008 6:50 PM > To: PHP Developers Mailing List > Subject: [PHP-DEV] json_encode() > > Ok, so as promised I ran some of the options we have that came up last > week by Douglas Crockford. > > 1. Document the fact that if you want to strictly conform to the JSON > spec and be sure your json_encode output will work in various JSON > parsers, you have to pass it a PHP array or object. > > 2. Remove support for basic types entirely and throw an error if you > pass json_encode() something that is not an array or an object. > > 3. Wrap basic types in an array [] by default and perhaps add an option > to json_encode() to skip the wrapper. > > He would prefer option 1. > > -Rasmus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.internals (#42270) next »