Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21610 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35693 invoked by uid 1010); 21 Jan 2006 02:30:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35677 invoked from network); 21 Jan 2006 02:30:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2006 02:30:06 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:12677] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 79/B3-10117-DAC91D34 for ; Fri, 20 Jan 2006 21:30:06 -0500 Received: (qmail 15641 invoked from network); 21 Jan 2006 02:30:00 -0000 Received: from localhost (HELO ANDI-NOTEBOOK.zend.com) (127.0.0.1) by localhost with SMTP; 21 Jan 2006 02:30:00 -0000 Message-ID: <7.0.0.16.2.20060120182610.041f6e70@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.0.16 Date: Fri, 20 Jan 2006 18:29:32 -0800 To: Rasmus Lerdorf Cc: internals@lists.php.net,omar@rmilk.com,crock@yahoo-inc.com In-Reply-To: <43D1960D.2060902@lerdorf.com> References: <43D13AAE.1030409@lerdorf.com> <7.0.0.16.2.20060120134701.04186f60@zend.com> <43D1625C.3030001@lerdorf.com> <7.0.0.16.2.20060120170223.041fb8d0@zend.com> <43D1960D.2060902@lerdorf.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] JSON inclusion in core From: andi@zend.com (Andi Gutmans) At 06:01 PM 1/20/2006, Rasmus Lerdorf wrote: >Andi Gutmans wrote: >>Yeah, but the main problem with this kind of stuff is when you >>start mapping classes and even references. I think it requires some >>additional pluming to be really useful for writing robust >>JavaScript<-->PHP connectivity so that it's flexible enough for all >>those PHP packages to start using it. >>I'm +1 for including JSON but not on the way the API is defined right now. > >I guess I am confused. Javascript, and thus JSON, has no concept of >an object. It has something it calls an object, but that is just an >associative array. Are you trying to layer some other syntax on top >of JSON to convey more meaning than what JSON/Javascript natively supports? Yes exactly. So for example, we should define some special string/value pair that conveys the class of the object (e.g. __classname:MyClass). I'd say that this is almost critical to allow a very nice mapping between the client side Javascript and the PHP layer. This way you can pretty much do a 1:1 mapping from Javascript objects (which might be nested) to PHP objects. The decode() would just find this __classname and make sure to instantiate MyClass and put the key/value pairs in that. I did look at Omar's code and it seems it doesn't have such provisions but that said, it's hard to review as I can't see any test cases nor documentation. Maybe Omar can work on that and then we can provide quick feedback and make sure we do something which we're all happy with. Seems like the existing functionality is 90% there. >I have looped in Douglas Crockford on this. I am about to hop on a >plane and will be somewhat out of touch for the next couple of days, >but he is the authority on this stuff so please run your proposed api by him. Great. Andi