* $foo = array( * 'integer' =>9, * 'string' =>'test string', * 'function' => Zend_Json_Expr( * 'function(){ window.alert("javascript function encoded by Zend_Json") }' * ), * ); * * Zend_Json::encode($foo, false, array('enableJsonExprFinder' => true)); * // it will returns json encoded string: * // {"integer":9,"string":"test string","function":function(){window.alert("javascript function encoded by Zend_Json")}} * * * @category Zend * @package Zend_Json * @subpackage Expr * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Json_Expr { /** * Storage for javascript expression. * * @var string */ protected $_expression; /** * Constructor * * @param string $expression the expression to hold. * @return void */ public function __construct($expression) { $this->_expression = (string) $expression; } /** * Cast to string * * @return string holded javascript expression. */ public function __toString() { return $this->_expression; } }