protected function _serialize($serialize)
    {
        $data = $this->_dataToSerialize($serialize);

        $jsonOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT |
            JSON_PARTIAL_OUTPUT_ON_ERROR;

        if (isset($this->viewVars['_jsonOptions'])) {
            if ($this->viewVars['_jsonOptions'] === false) {
                $jsonOptions = 0;
            } else {
                $jsonOptions = $this->viewVars['_jsonOptions'];
            }
        }

        if (Configure::read('debug')) {
            $jsonOptions |= JSON_PRETTY_PRINT;
        }

        return json_encode($data, $jsonOptions);
    }
protected function _serialize($serialize)
    {
        $data = $this->_dataToSerialize($serialize);

        $jsonOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT |
            JSON_PARTIAL_OUTPUT_ON_ERROR;

        if (isset($this->viewVars['_jsonOptions'])) {
            if ($this->viewVars['_jsonOptions'] === false) {
                $jsonOptions = 0;
            } else {
                $jsonOptions = $this->viewVars['_jsonOptions'];
            }
        }

        if (Configure::read('debug')) {
            $jsonOptions |= JSON_PRETTY_PRINT;
        }

        return json_encode($data, $jsonOptions);
    }
protected function _serialize ( $ serialize ) { $ data = $ this -> _dataToSerialize ( $ serialize ) ; $ jsonOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PARTIAL_OUTPUT_ON_ERROR ; if ( isset ( $ this -> viewVars [ '_jsonOptions' ] ) ) { if ( $ this -> viewVars [ '_jsonOptions' ] === false ) { $ jsonOptions = 0 ; } else { $ jsonOptions = $ this -> viewVars [ '_jsonOptions' ] ; } } if ( Configure :: read ( 'debug' ) ) { $ jsonOptions |= JSON_PRETTY_PRINT ; } return json_encode ( $ data , $ jsonOptions ) ; }
Serialize view vars

### Special parameters
`_jsonOptions` You can set custom options for json_encode() this way,
e.g. `JSON_HEX_TAG | JSON_HEX_APOS`.

@param array|string|bool $serialize The name(s) of the view variable(s)
that need(s) to be serialized. If true all available view variables.
@return string|false The serialized data, or boolean false if not serializable.
Serialize view vars