src/generic/controller.php
protected function responseJson($data, $status = null, $encodingOptions = 0)
    {
        $body = $this->_response->getBody();
        $body->rewind();
        $body->write($json = json_encode($data, $encodingOptions));
        // Ensure that the json encoding passed successfully
        if ($json === false) {
            throw new \RuntimeException(json_last_error_msg(), json_last_error());
        }
        $responseWithJson = $this->_response->withHeader('Content-Type', 'application/json;charset=utf-8');
        if (isset($status)) {
            return $responseWithJson->withStatus($status);
        }
        return $responseWithJson;
    }
protected function responseJson($data, $status = null, $encodingOptions = 0)
    {
        $body = $this->_response->getBody();
        $body->rewind();
        $body->write($json = json_encode($data, $encodingOptions));
        // Ensure that the json encoding passed successfully
        if ($json === false) {
            throw new \RuntimeException(json_last_error_msg(), json_last_error());
        }
        $responseWithJson = $this->_response->withHeader('Content-Type', 'application/json;charset=utf-8');
        if (isset($status)) {
            return $responseWithJson->withStatus($status);
        }
        return $responseWithJson;
    }
protected function responseJson ( $ data , $ status = null , $ encodingOptions = 0 ) { $ body = $ this -> _response -> getBody ( ) ; $ body -> rewind ( ) ; $ body -> write ( $ json = json_encode ( $ data , $ encodingOptions ) ) ; // Ensure that the json encoding passed successfully if ( $ json === false ) { throw new \ RuntimeException ( json_last_error_msg ( ) , json_last_error ( ) ) ; } $ responseWithJson = $ this -> _response -> withHeader ( 'Content-Type' , 'application/json;charset=utf-8' ) ; if ( isset ( $ status ) ) { return $ responseWithJson -> withStatus ( $ status ) ; } return $ responseWithJson ; }
transform response for with json-data
@param type $data
@param int $status
@param type $encodingOptions
@return \Zend\Diactoros\Response
@throws \RuntimeException
transform response for with json - data