Ces constantes sont définies par cette extension, et ne sont disponibles que si cette extension a été compilée avec PHP, ou bien chargée au moment de l'exécution.
Les constantes suivantes indiquent le type d'erreur retournée par la fonction json_last_error().
JSON_ERROR_NONE
(entier)
JSON_ERROR_DEPTH
(entier)
JSON_ERROR_STATE_MISMATCH
(entier)
JSON_ERROR_CTRL_CHAR
(entier)
JSON_ERROR_SYNTAX
(entier)
JSON_ERROR_UTF8
(entier)
JSON_ERROR_RECURSION
(integer)
JSON_PARTIAL_OUTPUT_ON_ERROR
a été fournie,
NULL
sera encodé à la place de la référence récursive.
Disponible depuis PHP 5.5.0.
JSON_ERROR_INF_OR_NAN
(integer)
NAN
,
soit INF
.
Si l'option JSON_PARTIAL_OUTPUT_ON_ERROR
a été fournie,
0 sera encodé à la place de ces nombres spéciaux.
Disponible depuis PHP 5.5.0.
JSON_ERROR_UNSUPPORTED_TYPE
(integer)
JSON_PARTIAL_OUTPUT_ON_ERROR
a été fournie,
NULL
sera encodé à la place de la valeur non supportée.
Disponible depuis PHP 5.5.0.
JSON_ERROR_INVALID_PROPERTY_NAME
(integer)
JSON_ERROR_UTF16
(integer)
Les constantes suivantes peuvent être combinées pour former les options de json_decode().
JSON_BIGINT_AS_STRING
(integer)
JSON_OBJECT_AS_ARRAY
(integer)
TRUE
.
Available since PHP 5.4.0.
Les constantes suivantes peuvent être combinées pour former les options de json_encode().
JSON_HEX_TAG
(entier)
JSON_HEX_AMP
(entier)
JSON_HEX_APOS
(entier)
JSON_HEX_QUOT
(entier)
JSON_FORCE_OBJECT
(entier)
JSON_NUMERIC_CHECK
(entier)
JSON_PRETTY_PRINT
(entier)
JSON_UNESCAPED_SLASHES
(entier)
JSON_UNESCAPED_UNICODE
(entier)
JSON_PARTIAL_OUTPUT_ON_ERROR
(integer)
JSON_PRESERVE_ZERO_FRACTION
(integer)
JSON_UNESCAPED_LINE_TERMINATORS
(integer)
JSON_UNESCAPED_UNICODE
est fourni. Il utilise le même
comportement comme si c'était avant PHP 7.1 sans cette constante.
Disponible depuis PHP 7.1.0.
Les constantes suivantes peuvent être combinées pour former les options de json_decode() et json_encode().
JSON_THROW_ON_ERROR
(integer)
JSON_PARTIAL_OUTPUT_ON_ERROR
prend la priorité par rapport à
JSON_THROW_ON_ERROR
.
Disponible depuis PHP 7.3.0.