Eric <[email protected]> wrote: > The easiest way to do that is to build a PHP array, and to use > JSON_Encode to convert it into a JSON encoded string;
Yes, that's the right way. If you aim for an associative array you should however watch out for a particular gotcha: If such an array has members, it will turn into a JSON/Javascript _object_, which is exactly what you want, but if once in a blue moon the associative PHP array happens to be empty, then you won't get an empty JSON/Javascript object, but an empty JSON/Javascript _array_! If you then do Object.keys(X).each() on that supposed object, you'll get a nasty surprise. So always check if your object is really an object. (I was bitten by this on several occasions, and it hurt.) -- Bertilo Wennergren [email protected] http://bertilow.com -- 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.
