« Programmation PHP/JSON » : différence entre les versions

Contenu supprimé Contenu ajouté
DannyS712 (discussion | contributions)
m <source> -> <syntaxhighlight> (phab:T237267)
Ligne 30 :
</syntaxhighlight>
}}
 
==== Options ====
Cette fonction peut renvoyer des erreurs visibles avec <code>json_last_error()</code>. Ex :
 
<syntaxhighlight lang=php>
$a = json_encode($monTableau);
if (json_last_error() === JSON_ERROR_INF_OR_NAN) {
$this->logger->error(json_last_error());
$a = json_encode($monTableau, JSON_PARTIAL_OUTPUT_ON_ERROR);
}
</syntaxhighlight>
 
=== json_decode() ===