Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42239 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98368 invoked from network); 13 Dec 2008 18:32:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2008 18:32:32 -0000 Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain prohost.org from 64.233.170.186 cause and error) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 64.233.170.186 rn-out-0910.google.com Received: from [64.233.170.186] ([64.233.170.186:44924] helo=rn-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/A7-47862-FBFF3494 for ; Sat, 13 Dec 2008 13:32:32 -0500 Received: by rn-out-0910.google.com with SMTP id 56so1734388rnw.8 for ; Sat, 13 Dec 2008 10:32:28 -0800 (PST) Received: by 10.65.242.7 with SMTP id u7mr4287275qbr.23.1229193148327; Sat, 13 Dec 2008 10:32:28 -0800 (PST) Received: from ?192.168.1.111? (CPE0018f8c0ee69-CM000f9f7d6664.cpe.net.cable.rogers.com [72.138.241.182]) by mx.google.com with ESMTPS id 9sm5206134qbw.21.2008.12.13.10.32.25 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 13 Dec 2008 10:32:26 -0800 (PST) Cc: Lukas Kahwe Smith , PHP Developers Mailing List Message-ID: <4BD2AEF7-C2E8-4A0C-8DC9-246B997AFF74@prohost.org> To: Scott MacVicar In-Reply-To: <275D06DD-2C64-4F88-8EF5-2AE46F94EF97@macvicar.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Date: Sat, 13 Dec 2008 13:32:24 -0500 References: <2D85B33E-889B-4214-9BB8-A12EFFFC641E@macvicar.net> <996B6F15-A0BC-4DE9-9486-BD7716F543C1@pooteeweet.org> <0E713C25-CBE4-4D33-8820-73AA15626EFC@prohost.org> <275D06DD-2C64-4F88-8EF5-2AE46F94EF97@macvicar.net> X-Mailer: Apple Mail (2.929.2) Subject: Re: [PHP-DEV] Re: Removing basic types from our JSON parser From: ilia@prohost.org (Ilia Alshanetsky) Please re-read my comments again. First of all RFC says that basic types are support even identifies them by name, secondly it says you MAY extend the syntax. What other languages do is fine and up to them to implement, unless you want to make a case for making PHP a copy of [language of your choice] then your argument has little merit IMO. On 13-Dec-08, at 1:24 PM, Scott MacVicar wrote: > The JSON grammar explicitly says that it's not supported. > > 2. JSON Grammar > A JSON text is a sequence of tokens. The set of tokens includes six > structural characters, strings, numbers, and three literal names. > A JSON text is a serialized object or array. > JSON-text = object / array > --- > As you can see the base type should be object / array. > To further test this I checked the python, ruby and perl > implementations and none of them support primitive types that aren't > in an array or object. > I then went and looked at the various JavaScript libraries and the > browser implementations and they all rejected the primitive types > and threw an error when trying to decode it. > Scott > On 13 Dec 2008, at 18:17, Ilia Alshanetsky wrote: > >> Lukas, >> >> Reading the spec it clearly says in the pre-amble that JSON can >> represent both primitive and complex data types >> >> From RFC: >> "JSON can represent four primitive types (strings, numbers, >> booleans, and null) and two structured types (objects and arrays)." >> >> The RFC also says that when it comes to parsers anything that >> matches the JSON grammar is valid, it even goes further that >> accepting "extensions" on top of the grammar is fine as well >> >> RFC: >> "A JSON parser MUST accept all texts that conform to the JSON >> grammar. A JSON parser MAY accept non-JSON forms or extensions." >> >> >> >> >> >> >> On 13-Dec-08, at 1:05 PM, Lukas Kahwe Smith wrote: >> >>> >>> On 13.12.2008, at 18:59, Ilia Alshanetsky wrote: >>> >>>> >>>> On 12-Dec-08, at 10:50 PM, Scott MacVicar wrote: >>>> >>>>> Hi All, >>>>> >>>>> Basic types were added to our JSON decoder to PHP 5.2.1, this >>>>> allows one to use json_encode / json_decode on any of our scalar >>>>> types. Omar correctly identified #38680 as not a bug but it >>>>> appears that Ilia added support for this anyway violating the >>>>> RFC [1]. Maybe there was a reason for this but I'm not sure why? >>>> >>>> PHP is typeless language, IMO its conductive to this design to >>>> allow encoding of basic types via json_encode, it reduces the >>>> code when communicating to/form JavaScript to avoid type >>>> detection. While it does violate the RFC IMO the convenience of >>>> the feature is definitely worth it. >>> >>> >>> well seems to me like its safer to stick with RFC as the default. >>> if at all this should be optional. JSON is a standard and this >>> requires everybody to follow it. so using something else should be >>> a conscious decision that is also visible during code review. >>> >>> regards, >>> Lukas Kahwe Smith >>> mls@pooteeweet.org >>> >>> >>> >> >> Ilia Alshanetsky >> >> >> >> > Ilia Alshanetsky