JSON expected, but getting error "view missing"

On a fresh install of 3.3.12, I tried to get JSON data from my project. According to the manual, putting this in my function (controller action) should be enough, except that I keep getting a “view missing” error.

public function jsonGet() {
	// Set the view vars that have to be serialized.
	$this->set('tags', $this->paginate());
	// Specify which view vars JsonView should serialize.
	$this->set('_serialize', ['tags']);
}

AppController::initialize() looks like this:

public function initialize() {
    parent::initialize();
    
    $this->loadComponent('RequestHandler');
    $this->loadComponent('Flash');
}

In the request an Accept-header is sent, with “application/json, text/javascript, /; q=0.01”.

What am I missing?

I usually return this:

//Return the status code
$this->response->statusCode(201);
//then:
return json_encode(value);

Then I get the error message “Controller actions can only return Cake\Network\Response or null.”.

Thanks for the pointer. I had found it, but as the question is not answered there, I am asking here.

As I see it, the poster on SO has the same problem as I have: though the old methods work, the current documentation says there are other, more modern ways, but seems faulty in explaining how they should work.