Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42267 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61912 invoked from network); 15 Dec 2008 18:09:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Dec 2008 18:09:51 -0000 Authentication-Results: pb1.pair.com header.from=mike503@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=mike503@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.198.231 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: mike503@gmail.com X-Host-Fingerprint: 209.85.198.231 rv-out-0506.google.com Received: from [209.85.198.231] ([209.85.198.231:57709] helo=rv-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 78/4A-24547-E6D96494 for ; Mon, 15 Dec 2008 13:09:51 -0500 Received: by rv-out-0506.google.com with SMTP id g37so2837853rvb.23 for ; Mon, 15 Dec 2008 10:09:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=7FIxJV/bm9aAAdwEueaIE9ITK+xBKH/K4dzu6RiEsO0=; b=BWh5APNe/1bjEIM+sU2ibJvXuG/VA4oWUbPXnAxUwGS3os4Vv74r4NbKD8yLnLZiMm QYAfIklDN6qtJryfCPoDnzayufREG0lh1zyEmpiijdSgR9LCZbxjK1d4madczliFtN5W Z6pXxSXeyR6BVGHkfzgCSrwwpziLL+p2tibA0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Vnibexna4NoyF68qI3KCVj56ulZUQC4j8nyvzhaoSSXR4MUZ0dS0GXs1XY9n4LLvRa BaZqap1bWfA8fKiZY7M/SPeTr3bQ49MaqnnzTsY236E109h+DHb+lHPd5wy6sNhziRpC Hzko59aoMBXEqp/uQk++BRAVpVTLx9FtUBNmo= Received: by 10.140.164.6 with SMTP id m6mr3849611rve.29.1229364587800; Mon, 15 Dec 2008 10:09:47 -0800 (PST) Received: by 10.141.152.1 with HTTP; Mon, 15 Dec 2008 10:09:47 -0800 (PST) Message-ID: Date: Mon, 15 Dec 2008 10:09:47 -0800 To: "Rasmus Lerdorf" Cc: "PHP Developers Mailing List" In-Reply-To: <494698D3.2030801@lerdorf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <494698D3.2030801@lerdorf.com> Subject: Re: [PHP-DEV] json_encode() From: mike503@gmail.com (mike) On Mon, Dec 15, 2008 at 9:50 AM, Rasmus Lerdorf wrote: > 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. Instead of json_encode(34) the suggestion would be json_encode(array(34)) ? Seems kind of like a lame thing to require. IMHO the language should "do the right thing" as far as the consumer (javascript/JSON parser) is concerned. However, Douglas is infinitely more educated than I am here. This is just my $0.02 as a PHP user. > 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. This sounds like what I had been talking about previously. > He would prefer option 1. I'd be tempted to say #3. However that's probably a code change everyone must make, I would expect that to be in a major release like 6.0.