The response goes as json if the client send the corresponding http header
If this header is not present the response is in xml
Rest client send this header automatically, browser no.
Thats why you get and xml accessing with a browser, try with a rest client or add the above header to your browser using an extension.
You can force json response globally in bootstrap section of your application configuration configuring the ContentNegotiator
'bootstrap' => [
'class' => 'yii\filters\ContentNegotiator',
'formats' => [
'application/json' => Response::FORMAT_JSON,