protected function jsonResponse($data)
    {
        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
        $resultJson = $this->resultJsonFactory->create();
        $resultJson->setHeader('Content-type', 'application/json', true);
        $resultJson->setData($data);
        return $resultJson;
    }
protected function jsonResponse($data)
    {
        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
        $resultJson = $this->resultJsonFactory->create();
        $resultJson->setHeader('Content-type', 'application/json', true);
        $resultJson->setData($data);
        return $resultJson;
    }
protected function jsonResponse ( $ data ) { /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $ resultJson = $ this -> resultJsonFactory -> create ( ) ; $ resultJson -> setHeader ( 'Content-type' , 'application/json' , true ) ; $ resultJson -> setData ( $ data ) ; return $ resultJson ; }
Build a JSON response

@param array $data Response data
@return \Magento\Framework\Controller\Result\Json
Build a JSON response