How to return JSON

my code

public function teste() {
        $usuario = $this->Usuarios->newEntity();
            '_serialize' => ['json'],
            'json' => $usuario,
        $this->set('_serialize', true);

but response contain layout (ex.: html, header, body, footer the cake debugger, etc), I just want string as a response.
I tryed
don’t work

Follow this section of the book: and don’t forget to enable

After that access your controller action with .json in the url. For example: $controller/teste.json

1 Like

I believe this is more like you want:

    $this->autoRender = false; 
    echo json_encode($any_content);

Sorry, but I could not understand the documentation

Din0saur thanks, It worked.