Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42270 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96389 invoked from network); 15 Dec 2008 20:55:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Dec 2008 20:55:33 -0000 Authentication-Results: pb1.pair.com header.from=thetaphi@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=thetaphi@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 80.190.230.99 as permitted sender) X-PHP-List-Original-Sender: thetaphi@php.net X-Host-Fingerprint: 80.190.230.99 www.troja.net Linux 2.5 (sometimes 2.4) (4) Received: from [80.190.230.99] ([80.190.230.99:38715] helo=mail.troja.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/C0-24547-444C6494 for ; Mon, 15 Dec 2008 15:55:33 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.troja.net (Postfix) with ESMTP id 943574E599 for ; Mon, 15 Dec 2008 21:55:29 +0100 (CET) Received: from mail.troja.net ([127.0.0.1]) by localhost (cyca.troja.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24211-09 for ; Mon, 15 Dec 2008 21:55:28 +0100 (CET) Received: from VEGA (port-83-236-62-11.dynamic.qsc.de [83.236.62.11]) (using SSLv3 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.troja.net (Postfix) with ESMTP id DC9744D4D2 for ; Mon, 15 Dec 2008 21:55:27 +0100 (CET) To: "'PHP Developers Mailing List'" References: <494698D3.2030801@lerdorf.com> Date: Mon, 15 Dec 2008 21:55:29 +0100 Message-ID: <7977336F527D4A70B0E4DD2870708686@VEGA> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <494698D3.2030801@lerdorf.com> Thread-Index: Acle3aVAl5eG1u71SraN00dOx02P9wAGcfww X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Subject: RE: [PHP-DEV] json_encode() From: thetaphi@php.net ("Uwe Schindler") 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