Re: JSON inclusion in core
| From: | l0t3k | Date: | Mon, 23 Jan 2006 23:27:03 +0000 |
| Subject: | Re: JSON inclusion in core | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-21662@lists.php.net to get a copy of this message | ||
"Bart de Boer" <bart@mediawave.nl> wrote in message
news:43D55D45.6010404@mediawave.nl...
> Bart de Boer wrote:
>> Bart
>
>
> I was wrong when I said that objects would be more consistent with the
> behaviour in JavaScript. When I said that I had the following JavaScript
> syntax in mind:
>
> object.property;
>
> of which the PHP equivalent would be:
>
> $object->property;
>
> But then Douglas Crockford got me thinking. And after snooping around at
> crockford.com I (re)discovered that objects can also be accessed like:
>
> object['property'];
>
> Which would be consistent with:
>
> $object['property'];
>
> So, making a long story short: And FWIW: I'm all +1 for implementing it as
> associative arrays. :)
The issue, though is that PHP's properties can be more than hashes (see
__get and __set), and setting (or reading) them can have useful side-effects
(think ORMs or RPC).
For people used to programming procedurally, you can continue using
associative arrays. But for people using objects, i imagine that a mapping
step from JSON encoded string to object would be the general case. If so, we
should by all means optimize for this case.
PDO and SOAP have mapping code, so there is prior art we can refer to.
l0t3k