|
|
|
@ -128,15 +128,19 @@ class Editor |
|
|
|
|
case 'boolean': |
|
|
|
|
return $var ? 'true' : 'false'; // Lowercase necessary! |
|
|
|
|
case 'integer': |
|
|
|
|
//no break |
|
|
|
|
case 'double': |
|
|
|
|
return (string)$var; |
|
|
|
|
//no break |
|
|
|
|
case 'resource': |
|
|
|
|
//no break |
|
|
|
|
case 'string': |
|
|
|
|
return '"'.str_replace( |
|
|
|
|
array("\r", "\n", "<", ">", "&"), |
|
|
|
|
array('\r', '\n', '\x3c', '\x3e', '\x26'), |
|
|
|
|
addslashes($var) |
|
|
|
|
).'"'; |
|
|
|
|
break; |
|
|
|
|
case 'array': |
|
|
|
|
// 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 |
|
|
|
@ -149,6 +153,7 @@ class Editor |
|
|
|
|
|
|
|
|
|
return '[ '.implode(', ', $output).' ]'; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'object': |
|
|
|
|
// Otherwise, fall through to convert the array as an object. |
|
|
|
|
$output = array(); |
|
|
|
@ -156,6 +161,7 @@ class Editor |
|
|
|
|
$output[] = $this->toJavascript(strval($k)).': '.$this->toJavascript($v); |
|
|
|
|
} |
|
|
|
|
return '{ '.implode(', ', $output).' }'; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
return 'null'; |
|
|
|
|
} |
|
|
|
|