Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42266 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58723 invoked from network); 15 Dec 2008 17:50:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Dec 2008 17:50:17 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Received: from [204.11.219.139] ([204.11.219.139:34244] helo=mail.lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AE/A9-24547-8D896494 for ; Mon, 15 Dec 2008 12:50:16 -0500 Received: from trainburn-lm.corp.yahoo.com (trainburn-lm.corp.yahoo.com [207.126.233.11]) (authenticated bits=0) by mail.lerdorf.com (8.14.3/8.14.3/Debian-6) with ESMTP id mBFHoC6L001010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Dec 2008 09:50:12 -0800 Message-ID: <494698D3.2030801@lerdorf.com> Date: Mon, 15 Dec 2008 09:50:11 -0800 User-Agent: Thunderbird 2.0.0.18 (Macintosh/20081105) MIME-Version: 1.0 To: PHP Developers Mailing List X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: json_encode() From: rasmus@lerdorf.com (Rasmus Lerdorf) 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