Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42254 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35781 invoked from network); 14 Dec 2008 14:48:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2008 14:48:57 -0000 Authentication-Results: pb1.pair.com header.from=rrichards@ctindustries.net; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=rrichards@ctindustries.net; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain ctindustries.net does not designate 207.58.142.210 as permitted sender) X-PHP-List-Original-Sender: rrichards@ctindustries.net X-Host-Fingerprint: 207.58.142.210 port80.smtp2go.com Linux 2.6 Received: from [207.58.142.210] ([207.58.142.210:60876] helo=srv2.smtp2go.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/D2-16810-8DC15494 for ; Sun, 14 Dec 2008 09:48:57 -0500 Received: from [67.158.171.203] (helo=rrichardsmbp.local) by srv2.smtp2go.com with esmtp (Exim 4.63) (envelope-from ) id 1LBsGz-0006t4-Cc; Sun, 14 Dec 2008 14:48:45 +0000 Message-ID: <49451CCC.2010008@ctindustries.net> Date: Sun, 14 Dec 2008 09:48:44 -0500 User-Agent: Thunderbird 2.0.0.18 (Macintosh/20081105) MIME-Version: 1.0 To: Scott MacVicar CC: Ilia Alshanetsky , Lukas Kahwe Smith , PHP Developers Mailing List 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> In-Reply-To: <275D06DD-2C64-4F88-8EF5-2AE46F94EF97@macvicar.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SMTP2Go-MailScanner-Information: Please contact support@smtp2go.com for more information X-SMTP2Go-MailScanner: Found to be clean X-SMTP2Go-MailScanner-From: rrichards@ctindustries.net Subject: Re: [PHP-DEV] Re: Removing basic types from our JSON parser From: rrichards@ctindustries.net (Rob Richards) It also says: 5. Generators A JSON generator produces JSON text. The resulting text MUST strictly conform to the JSON grammar. It says "JSON text" not JSON-text. There is no errata about this, so intended or not, PHP follows the spec. Rob 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 >> >> >> >> > >