Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35162 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54495 invoked by uid 1010); 4 Feb 2008 09:28:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 54480 invoked from network); 4 Feb 2008 09:28:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2008 09:28:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.94.239.7 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.94.239.7 mail.jdi-ict.nl Linux 2.6 Received: from [82.94.239.7] ([82.94.239.7:34128] helo=mail.jdi-ict.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/F6-07314-5CAD6A74 for ; Mon, 04 Feb 2008 04:28:37 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.jdi-ict.nl (8.13.7/8.12.11) with ESMTP id m149SYrV026430; Mon, 4 Feb 2008 10:28:34 +0100 Date: Mon, 4 Feb 2008 10:28:34 +0100 (CET) X-X-Sender: derick@kossu.ez.no To: Stanislav Malyshev cc: "'PHP Internals'" In-Reply-To: <47A66FBF.1040004@zend.com> Message-ID: References: <479A60BA.7030905@zend.com> <47A66FBF.1040004@zend.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Subject: Re: [PHP-DEV] json_encode() bug From: derick@php.net (Derick Rethans) On Sun, 3 Feb 2008, Stanislav Malyshev wrote: > > Like I mentioned before (I think), it should not return an empty string of > > course because programmatically it's not possible to check for this. As most > > of our functions return false in those cases, so should this function. > > AFAIR false is not valid JSON, so it would break a lot of code. Also, I am not > sure we should change json_encode to return false on whole structure if one of > the fields contains invalid utf-8. Of course we should make it possible to detect if there is broken data. I think our normal mantra is "be strict with creating, be lenient while parsing". Because we're generating data here, we should *abort* if we find an error, and not return half baked results. To detect if we have broken data, the option is to check a return value. As normally this function returns a string, false (or null) is a good candidate for an error-result. regards, Derick -- Derick Rethans http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org