Mike Naberezny wrote:
Bart de Boer wrote:
Maybe introduce an optional second argument "decodetype" to
json_decode() where you could pass on a constant like JSON_ARRAY or
JSON_OBJECT?
For example:
$assoc_array = json_decode($json_string, JSON_ARRAY);
$object = json_decode($json_string, JSON_OBJECT);
I'm not saying this is a bad idea but is it really necessary? It seems
to just add extra complexity. If json_decode() returns an associative
array then you can cast easily enough:
$obj = (object)json_decode($jsonSerialized);
Mike
That's not entirely true since the properties of the resulting object
would then still be made out of associative arrays. (in stead of objects)
I'm not saying it's necessary to have it return objects. I'm leaning
towards associative arrays myself too. On the other hand, objects seem
to be more consistent with the behaviour in Javascript. The specs seems
to allow both. Hence my suggestion.
Bart
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php