Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43313 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48196 invoked from network); 11 Mar 2009 19:47:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2009 19:47:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.220.158 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.220.158 mail-fx0-f158.google.com Received: from [209.85.220.158] ([209.85.220.158:41844] helo=mail-fx0-f158.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/68-09289-A3518B94 for ; Wed, 11 Mar 2009 14:47:07 -0500 Received: by fxm2 with SMTP id 2so138447fxm.23 for ; Wed, 11 Mar 2009 12:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=y+5Hd/iVuvmnYKIJHEVNBgLYvNyUcOm3+olKgmS75hc=; b=n205s4pxRpMBlFcs7ObtWxVTxXCbYjsmcOfzwqUApeyjb9S/TxC+vWf78kBSedOXUf jfAUSlyoEk+CzEGABkgom3tAfG8w07l3XdIfEuQVFfQ2fBGCQsdv4E3hNtuOsQw3U48t 12+KXVdG0GtFIb5bF3wBIriZ92pxrirqL139A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; b=f0JGE2PoTW0GkRPQlQoKtdbkAlff/yRS0014eyjfiuiAW07mDH6yBH16R7gHZqtQnX y34rL5y1TqjrDp+K02j6DYlKli/pSsIm8e2X/6a+0wWXdu57ozlUlYQjdB2EcI8oCZVc EWVzclz/gYbTAHh32H/eT92FX6e7H7SzJsYlA= MIME-Version: 1.0 Received: by 10.223.119.198 with SMTP id a6mr6710118far.42.1236800823108; Wed, 11 Mar 2009 12:47:03 -0700 (PDT) Reply-To: RQuadling@googlemail.com In-Reply-To: <8f5c52fe0903111225lbbfd07ek7f51c9f1f31877c0@mail.gmail.com> References: <10845a340903020821v718bc762g243864f7e098ee1c@mail.gmail.com> <49AC08EA.5000105@macvicar.net> <10845a340903020836u67ba1600qd4be7101f4256863@mail.gmail.com> <49AC0CB7.6@macvicar.net> <10845a340903100332v32aaa2bbs20316c2aea7738a5@mail.gmail.com> <8f5c52fe0903111225lbbfd07ek7f51c9f1f31877c0@mail.gmail.com> Date: Wed, 11 Mar 2009 19:47:02 +0000 Message-ID: <10845a340903111247o1c937d73o2e84ed26f83d291@mail.gmail.com> To: =?UTF-8?Q?Christopher_=C3=96stlund?= Cc: PHP Internals List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Patch and test cases too for From: rquadling@googlemail.com (Richard Quadling) 2009/3/11 Christopher =C3=96stlund : > I think this behavior is a bit odd too: > > php -r "echo json_encode(array(0=3D>'test'));" // ["test"] > php -r "echo json_encode(array(1=3D>'test'));" // {"1":"test"} > > And php -r "echo json_encode(array(0=3D>'test',3=3D>'foo'));" // {"0":"test","3= ":"foo"} So it seems that zero-base, sequential, integer indexed arrays will be output as a JS array and any other type of array will be an object hash. The PHP_JSON_FORCE_OBJECT (thank you Scott for the name) would at least clarify the output for dynamically created output. > > On Tue, Mar 10, 2009 at 11:32 AM, Richard Quadling > wrote: > >> 2009/3/2 Scott MacVicar : >> > Richard Quadling wrote: >> >> 2009/3/2 Scott MacVicar : >> >>> Richard Quadling wrote: >> >>>> Hi. >> >>>> >> >>>> Regarding http://bugs.php.net/bug.php?id=3D47493, I've supplied a p= atch >> >>>> to the unit tests too. >> >>>> >> >>>> Any chance this could get committed to 5.2+ >> >>>> >> >>> I'm too convinced of the parameter name and I don't think its someth= ing >> >>> that should be added to 5.2.9 since its a feature. >> >>> >> >>> Scott >> >>> >> >> >> >> 5.3+ would be OK then. >> >> >> >> As to the param name, I'm not actually changing the name, just adding >> >> another flag. >> >> >> >> In javascript's terminology,the output is an array ... >> >> >> >> [] >> >> >> >> or a hash >> >> >> >> {} >> >> >> >> So forcing a hash for arrays is pretty much what would be wanted and = I >> >> as I comment in the request, we have a "force" option when coming FRO= M >> >> json data ... json_decode ( string $json [, bool $assoc=3D false [, i= nt >> >> $depth=3D 512 ]] ) >> >> >> >> And the "name" of the param here is appropriate to PHP's use (assoc i= s >> >> not part of JSON's or JS's terminology). >> >> >> >> If you can think of a better name for the flag, then I'd be glad to u= se >> it. >> >> >> > >> > The JSON spec refers to them as arrays or objects though, as does our >> > documentation I believe. >> > >> > PHP_JSON_FORCE_OBJECT >> > >> > I however have another patch for more strict encoding so I'll try to >> > roll this in a single update. >> > >> > Scott >> > >> >> First of all, this isn't a "why is this not done yet" message. Honestly. >> >> Do you have any timeframe for this though? >> >> Do you think it will be ready for 5.3RC1? >> >> Thank you, >> >> Richard Quadling. >> >> -- >> ----- >> Richard Quadling >> Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213= 474731 >> "Standing on the shoulders of some very clever giants!" >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > --=20 ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474= 731 "Standing on the shoulders of some very clever giants!"