Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.611.2.1 diff -u -p -r1.611.2.1 common.inc --- includes/common.inc 14 Feb 2007 04:15:24 -0000 1.611.2.1 +++ includes/common.inc 8 Mar 2007 06:37:15 -0000 @@ -1699,14 +1699,17 @@ function drupal_to_js($var) { array('\r', '\n', '\x3c', '\x3e', '\x26'), addslashes($var)) .'"'; case 'array': - if (array_keys($var) === range(0, sizeof($var) - 1)) { + // Arrays in JSON can't be associative. If the array is empty or if it + // has sequential whole number keys starting with 0, it's not associative + // so we can go ahead and convert it as an array. + if (empty ($var) || array_keys($var) === range(0, sizeof($var) - 1)) { $output = array(); foreach ($var as $v) { $output[] = drupal_to_js($v); } return '[ '. implode(', ', $output) .' ]'; } - // Fall through + // Otherwise, fall through to convert the array as an object. case 'object': $output = array(); foreach ($var as $k => $v) {