src/Controller/Index.php
protected function createJsonResponse(array $variables)
    {
        $response = $this->getResponse();
        $json     = Json::encode($variables);
        $response->setContent($json);

        return $response;
    }
protected function createJsonResponse(array $variables)
    {
        $response = $this->getResponse();
        $json     = Json::encode($variables);
        $response->setContent($json);

        return $response;
    }
protected function createJsonResponse ( array $ variables ) { $ response = $ this -> getResponse ( ) ; $ json = Json :: encode ( $ variables ) ; $ response -> setContent ( $ json ) ; return $ response ; }
Create a json response object for ajax requests.

@param array $variables

@return \Zend\Stdlib\ResponseInterface
Create a json response object for ajax requests .