Arrays should only have entries with numeric keys (arrays are also objects, but you should not mix them).
If you convert the array to JSON, the process will only consider numeric properties. Other properties are simply ignored and therefore you get an empty array. Perhaps this is more obvious if you look at the length array:
> AssocArray.length 0
What is often called an "associative array" is actually just an object in JS:
var AssocArray = {};
Access to the properties of objects can be obtained using notation or dot notation of the array (if the key is not a reserved keyword). Thus, AssocArray.a same as AssocArray['a'] .
Felix Kling Dec 13 '10 at 2:03 2010-12-13 02:03
source share