Class for Zend\Json\Json encode method.

This class simply holds a string with a native Javascript Expression, so objects | arrays to be encoded with Zend\Json\Json can contain native Javascript Expressions.

Example:

$foo = array(
    'integer'  => 9,
    'string'   => 'test string',
    'function' => Zend\Json\Expr(
        'function () { window.alert("javascript function encoded by Zend\Json\Json") }'
    ),
);

Zend\Json\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\Json")}}

 Methods

Constructor

__construct(string $expression) 

Parameters

$expression

string

the expression to hold.

Cast to string

__toString() : string

Returns

stringholded javascript expression.

 Properties

 

Storage for javascript expression.

$expression : string