Bonjour
je voudrais récuperer des donnée sous format json car j'utilise mongodb avec cakephp 
j'ai mis ceci :
$patients = $this->Patient->find('all');
et voici le résultat :
array(
    (int) 0 => array(
        'Patient' => array(
            'reference' => 'p-203',
            'nom' => 'Moalla',
            'prenom' => 'Mehd',
            'birthdate' => '1988-08-08',
            'sexe' => 'M',
            'nationalite' => 'tun',
            'job' => 'etud',
            'adresse' => 'jhkjhkjhkjh',
            'ville' => 'tn',
            'tel' => '565478465',
            'email' => 'm@m.com',
            'note' => 'hghg',
            'age' => '20',
            'numss' => '36461654',
            'id' => '5489f9faec88a9202100002b'
        )
    )
)
je veux changer le format d'affichage vers json.<br/>
Merci.
  Il faut modifier plusieurs fichiers pour arriver à ça:
// app/Config/routes.php
Router::parseExtensions('json');
// app/Controller/PatientsController.php
public $components = array('RequestHandler');
public function index() {
    $patients = $this->Patient->find('all');
    // En suite, deux façon de récupérer les données json:
    // - Sans passer par un traitement de vue
    $this->set('_serialize', array('patients'));
    // - En passant par une vue
    $this->set(compact('posts', 'comments'));
}
// app/View/Patients/json/index.ctp (Si tu utilise la deuxième méthode dans ton action)
<?= debug($patients); ?>
La documentation CakePHP (en français) au cas ou: