public function sendJson($values, $code = 200, array $headers = null)
{
// Build the response and send it
$response = new Response();
$this->response->setCode($code);
if (null !== $headers) {
foreach ($headers as $name => $value) {
$this->response->setHeader($name, $value);
}
}
// Force JSON content-type header
$response->setHeader('Content-Type', 'application/json')->setBody(json_encode($values));
$response->send();
}