2009/5/29 disccomp <[email protected]>:
>
> I came across this quirk in PHP as well. IMHO, it is much better to
> fix the code on the server side than it would be to mess with
> (correctly functioning) code on the client. -Mark
> >
>

"Quirk"? I don't think this is a quirk.

At what stage should a string be automatically be thought of as a
single element in an array.

They shouldn't be.

A string is a string and an array is an array (ok, some people think
of a string as an array of characters, but that's not what we are
talking about here).

As such JSON encoding supports both types correctly.

There was an issue with PHP where say you were encoding the results of
an SQL query and using associative indicies, getting a result and
getting no results would result in different types in the JSON output.

This is why the JSON_FORCE_OBJECT option was added (currently in PHP
5.3.0). This allows you to force objects for arrays with no data or
zero-based, sequential numeric keys.

When the data arrives in the JS domain, it is an object all the time.
Very useful.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to