Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42244 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82127 invoked from network); 14 Dec 2008 06:32:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2008 06:32:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=mike503@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mike503@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.198.225 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.225 rv-out-0506.google.com Received: from [209.85.198.225] ([209.85.198.225:18571] helo=rv-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/73-47862-C78A4494 for ; Sun, 14 Dec 2008 01:32:29 -0500 Received: by rv-out-0506.google.com with SMTP id g37so2206068rvb.23 for ; Sat, 13 Dec 2008 22:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:references:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:x-mailer :mime-version:subject:date:cc; bh=2j7yxjwPoUAlqpQDM5ZO1V3yNTezT68uj6Mz11MGqOY=; b=jaivTsW+JfYrOYYVZvfDE+qWHcaFswWmm4hCvKcyL4uzU1getz90q1KshRq2eZgxGZ RcDK6O0gZpECH1Xsm6pqGhQkopYjEcYshPfNPVmjVun7d783ffrVsGMKr0wbXEb14OeG 6NBkGD7aKRkp3w4O5mocw+DZ99M4woJ2ZKOQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:x-mailer:mime-version:subject:date:cc; b=O/MWHBSa413xjKkwLo42n9tQBhIC9+IbIhX5JMD/Jx6mnhyXLfgfiNscTvOoYfo0n1 VQkIj3vmYjq7InXWy8oAbWnVC5bMMK4WpfpF3x2+ybuEs4+H98zPySgtakqTc5yYNwRH /3WMAxTqSu9//WfBcL9cSMEnX/SNJK6dUp614= Received: by 10.141.152.9 with SMTP id e9mr1986731rvo.189.1229236346472; Sat, 13 Dec 2008 22:32:26 -0800 (PST) Received: from ?10.80.93.72? ([32.152.14.134]) by mx.google.com with ESMTPS id b39sm673537rvf.0.2008.12.13.22.32.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 13 Dec 2008 22:32:25 -0800 (PST) References: <2D85B33E-889B-4214-9BB8-A12EFFFC641E@macvicar.net> <1229150500.30719.201.camel@localhost> <4BA26FE8A9634178B4CEBEFA818810D2@VEGA> <15E310EAB433466EAF996B252CBED2BB@pc> <49448D66.2030501@lerdorf.com> <28139bc0812132210p1ed94f4ds40e31ff499cf2e7@mail.gmail.com> Message-ID: <7463F1E1-A880-479F-9584-30FFCED6E614@gmail.com> To: "moo.tinys" In-Reply-To: <28139bc0812132210p1ed94f4ds40e31ff499cf2e7@mail.gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Mailer: iPhone Mail (5G77) Mime-Version: 1.0 (iPhone Mail 5G77) Date: Sat, 13 Dec 2008 22:31:18 -0800 Cc: Rasmus Lerdorf , Stan Vassilev | FM , PHP Developers Mailing List Subject: Re: [PHP-DEV] Removing basic types from our JSON parser From: mike503@gmail.com (mike) Sorry for top posting. I see no reason why php should not interop with javascript 100% as it should. I do not see a reason to create new functions, parameters, etc. The existing should be expected to both encode and decode json with javascript properly. If there is a mismatch right now, then it should be fixed. On Dec 13, 2008, at 10:10 PM, moo.tinys wrote: >> >> I'm not sure if that is the right way of looking at it though. I >> think >> the only question is how to represent the scalar types, not whether >> they >> should be allowed. As far as I am concerned it is obvious that >> they be >> allowed and the JSON spec is quite explicit that JSON can be used to >> represent scalar types: >> >> JSON can represent four primitive types (strings, numbers, >> booleans, and null) and two structured types (objects and arrays). >> >> The only question is how to serialize these into a JSON-text string. >> Again, from the RFC: >> >> 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. >> >> This last statement is the issue. When serializing a basic type >> into a >> JSON text string, the RFC says we need to wrap it inside an array or >> object. So, if we are going to add an option to json_encode(), >> that's >> what the option should do. Specify whether, and perhaps how, to wrap >> basic types, not whether to allow or disallow them. >> >> I'll talk to Douglas on Monday if he is in the office and get his >> opinion. >> >> -Rasmus > cool. > let's see how :D. Crockford explain it :D > but before he can react on this thread, i guess Rasmus is right > understanding the RFC. > json force your encoder to output the following in encoded form > 1. array: "multiple of unnamed" values > 2. object: "multiple of named" values > so it's right to "wrap it" in object or array (u can say "remove > basic types") > > json_encode(array(1)); => [1] > json_encode(array(1, 2, 3, "1")); => [1,2,3,"1"] > > json_encode(array('value1' => 1)); => {"value1":1} > json_encode(array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>"1")); => {"a":1, > "b":2,"c":3,"d":"1"} > > i'd prefer 2 new functions: js_encode (or js_export?) js_decode which > support basic types instead of having an extra optional parameter > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >