code: public function sendJson($data, $statusCode = null)
      {
          return $this->setStatusCode($statusCode)
                      ->setJsonBody($data)
                      ->send();
      }
docs: Send JSON response with an optional statuscode.
  
  @param mixed   $data       to be encoded as json.
  @param integer $statusCode optional statuscode to send.
  
  @return self