Estas constantes están definidas por esta extensión y estarán disponibles sólo cuando la extensión haya sido compilada con PHP, o bien sea cargada dinámicamente en ejecución.
Las siguientes constantes indican el tipo de error retornado por json_last_error().
JSON_ERROR_NONE
(integer)
JSON_ERROR_DEPTH
(integer)
JSON_ERROR_STATE_MISMATCH
(integer)
JSON_ERROR_CTRL_CHAR
(integer)
JSON_ERROR_SYNTAX
(integer)
JSON_ERROR_UTF8
(integer)
JSON_ERROR_RECURSION
(integer)
El objeto o array pasado a json_encode() incluye
referencias recursivas y no se puede codificar.
Si se proporcionó la opción JSON_PARTIAL_OUTPUT_ON_ERROR
,
se codificará null
en el lugar de la referencia recursiva.
JSON_ERROR_INF_OR_NAN
(integer)
El valor pasado a json_encode() incluye
NAN
o INF
.
Si se proporcionó la opción JSON_PARTIAL_OUTPUT_ON_ERROR
,
se codificará 0
en el lugar de estos números
especiales.
JSON_ERROR_UNSUPPORTED_TYPE
(integer)
Se proporcionó un valor de un tipo no admitido para
json_encode(), tal como un resource.
Si se proporcionó la opción JSON_PARTIAL_OUTPUT_ON_ERROR
,
se codificará null
en el lugar del valor no admitido.
JSON_ERROR_INVALID_PROPERTY_NAME
(integer)
Se ha usado una clave que empieza con el caracter \u0000 en la cadena de texto pasada a json_encode() al decodificar un objeto JSON en un objeto PHP.
JSON_ERROR_UTF16
(integer)
Un único sustituto UTF-16 no emparejado en una secuencia de escape unicode contenida en la cadena JSON pasada a json_encode().
Las siguientes constantes se pueden combinar para obtener opciones para json_encode().
JSON_HEX_TAG
(integer)
JSON_HEX_AMP
(integer)
JSON_HEX_APOS
(integer)
JSON_HEX_QUOT
(integer)
JSON_FORCE_OBJECT
(integer)
JSON_NUMERIC_CHECK
(integer)
JSON_BIGINT_AS_STRING
(integer)
JSON_OBJECT_AS_ARRAY
(integer)
true
JSON_PRETTY_PRINT
(integer)
JSON_UNESCAPED_SLASHES
(integer)
/
.
JSON_UNESCAPED_UNICODE
(integer)
JSON_PARTIAL_OUTPUT_ON_ERROR
(integer)
JSON_PRESERVE_ZERO_FRACTION
(integer)
JSON_UNESCAPED_LINE_TERMINATORS
(int)
JSON_UNESCAPED_UNICODE
.
Utiliza el mismo comportamiento que tenía antes de PHP 7.1 sin
esta constante. Disponible desde PHP 7.1.0.
Las siguientes constantes pueden combinarse para formar opciones para json_decode() y json_encode().
JSON_INVALID_UTF8_IGNORE
(int)
JSON_INVALID_UTF8_SUBSTITUTE
(int)
JSON_THROW_ON_ERROR
(int)
JSON_PARTIAL_OUTPUT_ON_ERROR
tiene prioridad sobre
JSON_THROW_ON_ERROR
.
Disponible desde PHP 7.3.0.
JSON_ERROR_NON_BACKED_ENUM
(int)