Place this over the original Object method in the javascript.php
located in "\cake\libs\view\helpers\".
Enjoy.

function object($data, $block = false, $prefix = '', $postfix = '',
$stringKeys = array(), $quoteKeys = true, $q = "\"")
        {
            $parts = array();
            $is_list = false;

            $keys = array_keys($data);
            $max_length = count($data)-1;

            if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {
                $is_list = true;

                for($i=0; $i<count($keys); $i++) {
                    if($i != $keys[$i]) {
                        $is_list = false;
                        break;
                    }
                }

            }

            foreach($data as $key=>$value) {
                if(is_array($value)) {
                    if($is_list) $parts[] = $this->object($value, false, '',
'', $stringKeys, $quoteKeys, $q);
                    else $parts[] = $q . $this->escapeString($key) . $q .
':' . $this->object($value, false, '', '', $stringKeys, $quoteKeys,
$q);
                } else {
                    $str = '';
                    if(!$is_list) $str = $q . $this->escapeString($key) .
$q .':';

                    if(is_numeric($value)) $str .= $value;
                    elseif($value === false) $str .= 'false';
                    elseif($value === true) $str .= 'true';
                    else $str .= $q . $this->escapeString($value) . $q;

                    $parts[] = $str;
                }
            }
            $json = implode(',',$parts);

            if($is_list) return '[' . $json . ']';
            else $rt = '{' . $json . '}';

            $rt = $prefix . $rt . $postfix;

            if($block)
            {
                $rt = $this->codeBlock($rt);
            }

            return $rt;
        }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to