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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php