How to return JSON

I believe this is more like you want:

    $this->RequestHandler->respondAs('json');
    $this->response->type('application/json');  
    $this->autoRender = false; 
    echo json_encode($any_content);
3 Likes