On 05/31/2011 02:34 PM, Dan Birken wrote:
> It is worth noting that point you bring up is one that is present in PHP
> currently:
> 
> php > print_r(json_decode(json_encode(array('a' => 'b'))));
> stdClass Object
> (
>     [a] => b
> )
> 
> php > print_r(json_decode(json_encode(array('a', 'b'))));
> Array
> (
>     [0] => a
>     [1] => b
> )

Sure, but that makes makes perfect sense, does it not? Javascript does
not have associative arrays. So any non-scalar array has to be mapped to
a Javascript object in order to be represented. When we bring it back we
map a Javascript object to a PHP object, however, there is an optional
argument on json_decode() to change that to an associative array if desired.

The point we are making is that this exact inability of the json
notation to distinguish an associative array from an object makes it a
problematic choice for a native syntax in PHP.

-Rasmus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to