Database Query as json string

$user = $this->find()->toArray();
this->set(compact(‘user’));
$this->viewBuilder()->setOption(‘serialize’, ‘user’);