title: How to convert an array to json in yii2
body: <p>I am creating <code>restful apis</code> and I had a function to send response data in <code>yii1</code> like this</p>
  
  <pre><code>public function sendResponse($data)
  {
      header('Content-Type: application/json; charset=utf-8');
      echo CJSON::encode($data);
      exit;
  }
  </code></pre>
  
  <p><code>CJSON</code> is not available in <code>Yii2</code> so how do i do it in <code>Yii2</code></p>