private function outputResponse($body, $httpStatus = 200)
 {
     status_header($httpStatus);
     header('Content-Type: application/json');
     echo wsh_pretty_json(json_encode($body));
 }
Exemple #2
0
 /**
  * Output something as JSON.
  *
  * @param mixed $response
  */
 protected function outputAsJson($response)
 {
     header('Content-Type: application/json; charset=utf-8');
     if (defined('JSON_PRETTY_PRINT')) {
         $output = json_encode($response, JSON_PRETTY_PRINT);
     } elseif (function_exists('wsh_pretty_json')) {
         $output = wsh_pretty_json(json_encode($response));
     } else {
         $output = json_encode($response);
     }
     echo $output;
 }