Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42238 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96788 invoked from network); 13 Dec 2008 18:24:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2008 18:24:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=scott@macvicar.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=scott@macvicar.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain macvicar.net from 193.227.246.108 cause and error) X-PHP-List-Original-Sender: scott@macvicar.net X-Host-Fingerprint: 193.227.246.108 ip246-108-v193.static.x-ip.net Received: from [193.227.246.108] ([193.227.246.108:42331] helo=lovelace.midden.org.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 63/67-47862-3EDF3494 for ; Sat, 13 Dec 2008 13:24:36 -0500 Received: from macvicar.demon.co.uk ([80.177.111.173] helo=[192.168.1.100]) by lovelace.midden.org.uk with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1LBZAD-0001b6-Ib; Sat, 13 Dec 2008 18:24:32 +0000 Cc: Lukas Kahwe Smith , PHP Developers Mailing List Message-ID: <275D06DD-2C64-4F88-8EF5-2AE46F94EF97@macvicar.net> To: Ilia Alshanetsky In-Reply-To: <0E713C25-CBE4-4D33-8820-73AA15626EFC@prohost.org> 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 18:24:23 +0000 References: <2D85B33E-889B-4214-9BB8-A12EFFFC641E@macvicar.net> <996B6F15-A0BC-4DE9-9486-BD7716F543C1@pooteeweet.org> <0E713C25-CBE4-4D33-8820-73AA15626EFC@prohost.org> X-Mailer: Apple Mail (2.929.2) X-Spam-Score: -4.1 X-Spam_Report: Spam detection software, running on the system "lovelace.midden.org.uk", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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: [...] Content analysis details: (-4.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.3 AWL AWL: From: address is in the auto white-list Subject: Re: [PHP-DEV] Re: Removing basic types from our JSON parser From: scott@macvicar.net (Scott MacVicar) 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 > > > >