2006-05-05 15:49:42 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2014-09-19 16:33:14 +00:00
|
|
|
| PHP Version 7 |
|
2006-05-05 15:49:42 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2015-01-15 15:27:30 +00:00
|
|
|
| Copyright (c) 1997-2015 The PHP Group |
|
2006-05-05 15:49:42 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.php.net/license/3_01.txt |
|
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Omar Kilani <omar@php.net> |
|
2015-09-04 18:56:59 +00:00
|
|
|
| Jakub Zelenka <bukka@php.net> |
|
2006-05-05 15:49:42 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "php.h"
|
|
|
|
#include "php_ini.h"
|
|
|
|
#include "ext/standard/info.h"
|
2012-11-25 07:14:23 +00:00
|
|
|
#include "ext/standard/html.h"
|
2014-09-20 20:42:02 +00:00
|
|
|
#include "zend_smart_str.h"
|
2006-05-05 15:49:42 +00:00
|
|
|
#include "php_json.h"
|
2014-11-24 20:46:13 +00:00
|
|
|
#include "php_json_encoder.h"
|
|
|
|
#include "php_json_parser.h"
|
2010-05-06 13:44:35 +00:00
|
|
|
#include <zend_exceptions.h>
|
2006-05-05 15:49:42 +00:00
|
|
|
|
2014-03-29 23:41:48 +00:00
|
|
|
#include <float.h>
|
|
|
|
#if defined(DBL_MANT_DIG) && defined(DBL_MIN_EXP)
|
|
|
|
#define NUM_BUF_SIZE (3 + DBL_MANT_DIG - DBL_MIN_EXP)
|
|
|
|
#else
|
|
|
|
#define NUM_BUF_SIZE 1080
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-08-14 20:08:18 +00:00
|
|
|
static PHP_MINFO_FUNCTION(json);
|
|
|
|
static PHP_FUNCTION(json_encode);
|
|
|
|
static PHP_FUNCTION(json_decode);
|
2008-12-19 02:00:57 +00:00
|
|
|
static PHP_FUNCTION(json_last_error);
|
2012-06-28 18:09:47 +00:00
|
|
|
static PHP_FUNCTION(json_last_error_msg);
|
2006-08-14 20:08:18 +00:00
|
|
|
|
2014-02-17 09:25:40 +00:00
|
|
|
PHP_JSON_API zend_class_entry *php_json_serializable_ce;
|
2010-05-05 22:48:14 +00:00
|
|
|
|
2015-09-03 18:28:34 +00:00
|
|
|
PHP_JSON_API ZEND_DECLARE_MODULE_GLOBALS(json)
|
2008-12-19 02:00:57 +00:00
|
|
|
|
2008-06-27 19:16:17 +00:00
|
|
|
/* {{{ arginfo */
|
|
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_json_encode, 0, 0, 1)
|
|
|
|
ZEND_ARG_INFO(0, value)
|
2008-12-17 14:40:06 +00:00
|
|
|
ZEND_ARG_INFO(0, options)
|
2012-07-24 11:15:16 +00:00
|
|
|
ZEND_ARG_INFO(0, depth)
|
2008-06-27 19:16:17 +00:00
|
|
|
ZEND_END_ARG_INFO()
|
|
|
|
|
|
|
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_json_decode, 0, 0, 1)
|
|
|
|
ZEND_ARG_INFO(0, json)
|
|
|
|
ZEND_ARG_INFO(0, assoc)
|
2009-05-15 09:10:55 +00:00
|
|
|
ZEND_ARG_INFO(0, depth)
|
2010-05-21 22:59:58 +00:00
|
|
|
ZEND_ARG_INFO(0, options)
|
2008-06-27 19:16:17 +00:00
|
|
|
ZEND_END_ARG_INFO()
|
2008-12-19 02:00:57 +00:00
|
|
|
|
2012-06-28 18:09:47 +00:00
|
|
|
ZEND_BEGIN_ARG_INFO(arginfo_json_last_error, 0)
|
|
|
|
ZEND_END_ARG_INFO()
|
|
|
|
|
|
|
|
ZEND_BEGIN_ARG_INFO(arginfo_json_last_error_msg, 0)
|
2008-12-19 02:00:57 +00:00
|
|
|
ZEND_END_ARG_INFO()
|
2008-06-27 19:16:17 +00:00
|
|
|
/* }}} */
|
|
|
|
|
2008-12-19 02:00:57 +00:00
|
|
|
/* {{{ json_functions[] */
|
2010-03-30 23:03:02 +00:00
|
|
|
static const zend_function_entry json_functions[] = {
|
2008-07-22 15:30:03 +00:00
|
|
|
PHP_FE(json_encode, arginfo_json_encode)
|
|
|
|
PHP_FE(json_decode, arginfo_json_decode)
|
2008-12-19 02:00:57 +00:00
|
|
|
PHP_FE(json_last_error, arginfo_json_last_error)
|
2012-06-28 18:09:47 +00:00
|
|
|
PHP_FE(json_last_error_msg, arginfo_json_last_error_msg)
|
2011-07-25 11:35:02 +00:00
|
|
|
PHP_FE_END
|
2006-05-05 15:49:42 +00:00
|
|
|
};
|
|
|
|
/* }}} */
|
|
|
|
|
2010-05-12 16:42:48 +00:00
|
|
|
/* {{{ JsonSerializable methods */
|
2010-05-05 22:48:14 +00:00
|
|
|
ZEND_BEGIN_ARG_INFO(json_serialize_arginfo, 0)
|
|
|
|
/* No arguments */
|
|
|
|
ZEND_END_ARG_INFO();
|
|
|
|
|
|
|
|
static const zend_function_entry json_serializable_interface[] = {
|
2010-05-12 16:42:48 +00:00
|
|
|
PHP_ABSTRACT_ME(JsonSerializable, jsonSerialize, json_serialize_arginfo)
|
2011-08-06 01:22:27 +00:00
|
|
|
PHP_FE_END
|
2010-05-05 22:48:14 +00:00
|
|
|
};
|
2010-09-16 14:15:19 +00:00
|
|
|
/* }}} */
|
2010-05-05 22:48:14 +00:00
|
|
|
|
2015-09-04 19:00:29 +00:00
|
|
|
/* Register constant for options and errors */
|
|
|
|
#define PHP_JSON_REGISTER_CONSTANT(_name, _value) \
|
|
|
|
REGISTER_LONG_CONSTANT(_name, _value, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
2007-12-17 07:48:27 +00:00
|
|
|
/* {{{ MINIT */
|
|
|
|
static PHP_MINIT_FUNCTION(json)
|
|
|
|
{
|
2010-05-05 22:48:14 +00:00
|
|
|
zend_class_entry ce;
|
|
|
|
|
2010-05-12 16:42:48 +00:00
|
|
|
INIT_CLASS_ENTRY(ce, "JsonSerializable", json_serializable_interface);
|
2014-12-13 22:06:14 +00:00
|
|
|
php_json_serializable_ce = zend_register_internal_interface(&ce);
|
2010-05-05 22:48:14 +00:00
|
|
|
|
2015-09-04 19:00:29 +00:00
|
|
|
/* options for json_encode */
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_HEX_TAG", PHP_JSON_HEX_TAG);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_HEX_AMP", PHP_JSON_HEX_AMP);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_HEX_APOS", PHP_JSON_HEX_APOS);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_HEX_QUOT", PHP_JSON_HEX_QUOT);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_FORCE_OBJECT", PHP_JSON_FORCE_OBJECT);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_NUMERIC_CHECK", PHP_JSON_NUMERIC_CHECK);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_UNESCAPED_SLASHES", PHP_JSON_UNESCAPED_SLASHES);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_PRETTY_PRINT", PHP_JSON_PRETTY_PRINT);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_UNESCAPED_UNICODE", PHP_JSON_UNESCAPED_UNICODE);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_PARTIAL_OUTPUT_ON_ERROR", PHP_JSON_PARTIAL_OUTPUT_ON_ERROR);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_PRESERVE_ZERO_FRACTION", PHP_JSON_PRESERVE_ZERO_FRACTION);
|
|
|
|
|
|
|
|
/* options for json_decode */
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_OBJECT_AS_ARRAY", PHP_JSON_OBJECT_AS_ARRAY);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_BIGINT_AS_STRING", PHP_JSON_BIGINT_AS_STRING);
|
|
|
|
|
|
|
|
/* json error constants */
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_NONE", PHP_JSON_ERROR_NONE);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_DEPTH", PHP_JSON_ERROR_DEPTH);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_STATE_MISMATCH", PHP_JSON_ERROR_STATE_MISMATCH);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_CTRL_CHAR", PHP_JSON_ERROR_CTRL_CHAR);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_SYNTAX", PHP_JSON_ERROR_SYNTAX);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_UTF8", PHP_JSON_ERROR_UTF8);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_RECURSION", PHP_JSON_ERROR_RECURSION);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_INF_OR_NAN", PHP_JSON_ERROR_INF_OR_NAN);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_UNSUPPORTED_TYPE", PHP_JSON_ERROR_UNSUPPORTED_TYPE);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_INVALID_PROPERTY_NAME", PHP_JSON_ERROR_INVALID_PROPERTY_NAME);
|
|
|
|
PHP_JSON_REGISTER_CONSTANT("JSON_ERROR_UTF16", PHP_JSON_ERROR_UTF16);
|
2010-05-21 22:59:58 +00:00
|
|
|
|
2007-12-17 07:48:27 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2008-12-19 02:00:57 +00:00
|
|
|
/* {{{ PHP_GINIT_FUNCTION
|
|
|
|
*/
|
|
|
|
static PHP_GINIT_FUNCTION(json)
|
|
|
|
{
|
2014-10-17 12:16:40 +00:00
|
|
|
#if defined(COMPILE_DL_JSON) && defined(ZTS)
|
2015-02-16 16:19:32 +00:00
|
|
|
ZEND_TSRMLS_CACHE_UPDATE();
|
2014-10-17 12:16:40 +00:00
|
|
|
#endif
|
2010-09-16 16:21:15 +00:00
|
|
|
json_globals->encoder_depth = 0;
|
2008-12-19 02:00:57 +00:00
|
|
|
json_globals->error_code = 0;
|
2012-07-24 11:15:16 +00:00
|
|
|
json_globals->encode_max_depth = 0;
|
2008-12-19 02:00:57 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2007-12-17 07:48:27 +00:00
|
|
|
|
2006-05-05 15:49:42 +00:00
|
|
|
/* {{{ json_module_entry
|
|
|
|
*/
|
|
|
|
zend_module_entry json_module_entry = {
|
2008-07-22 15:30:03 +00:00
|
|
|
STANDARD_MODULE_HEADER,
|
|
|
|
"json",
|
|
|
|
json_functions,
|
|
|
|
PHP_MINIT(json),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
PHP_MINFO(json),
|
|
|
|
PHP_JSON_VERSION,
|
2008-12-19 02:00:57 +00:00
|
|
|
PHP_MODULE_GLOBALS(json),
|
|
|
|
PHP_GINIT(json),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
STANDARD_MODULE_PROPERTIES_EX
|
2006-05-05 15:49:42 +00:00
|
|
|
};
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
#ifdef COMPILE_DL_JSON
|
2014-10-17 12:16:40 +00:00
|
|
|
#ifdef ZTS
|
2015-02-16 16:19:32 +00:00
|
|
|
ZEND_TSRMLS_CACHE_DEFINE();
|
2014-10-17 12:16:40 +00:00
|
|
|
#endif
|
2006-05-05 15:49:42 +00:00
|
|
|
ZEND_GET_MODULE(json)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* {{{ PHP_MINFO_FUNCTION
|
|
|
|
*/
|
2006-08-14 20:08:18 +00:00
|
|
|
static PHP_MINFO_FUNCTION(json)
|
2006-05-05 15:49:42 +00:00
|
|
|
{
|
2008-07-22 15:30:03 +00:00
|
|
|
php_info_print_table_start();
|
|
|
|
php_info_print_table_row(2, "json support", "enabled");
|
|
|
|
php_info_print_table_row(2, "json version", PHP_JSON_VERSION);
|
|
|
|
php_info_print_table_end();
|
2006-05-05 15:49:42 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options) /* {{{ */
|
2007-07-23 12:24:52 +00:00
|
|
|
{
|
2014-12-27 19:42:04 +00:00
|
|
|
php_json_encode_zval(buf, val, options);
|
2006-05-05 15:49:42 +00:00
|
|
|
}
|
2007-07-23 12:24:52 +00:00
|
|
|
/* }}} */
|
2006-05-05 15:49:42 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */
|
2006-05-05 15:49:42 +00:00
|
|
|
{
|
2014-11-24 20:46:13 +00:00
|
|
|
php_json_parser parser;
|
2008-07-22 15:30:03 +00:00
|
|
|
|
2015-02-09 10:06:02 +00:00
|
|
|
php_json_parser_init(&parser, return_value, str, str_len, (int)options, (int)depth);
|
2008-07-22 15:30:03 +00:00
|
|
|
|
2014-11-24 20:46:13 +00:00
|
|
|
if (php_json_yyparse(&parser)) {
|
|
|
|
JSON_G(error_code) = php_json_parser_error_code(&parser);
|
2009-05-14 22:02:08 +00:00
|
|
|
RETURN_NULL();
|
2008-12-17 14:40:06 +00:00
|
|
|
}
|
2006-05-05 15:49:42 +00:00
|
|
|
}
|
2007-05-25 13:24:50 +00:00
|
|
|
/* }}} */
|
2006-05-05 15:49:42 +00:00
|
|
|
|
2012-07-29 15:35:06 +00:00
|
|
|
/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
|
2009-05-31 01:44:07 +00:00
|
|
|
Returns the JSON representation of a value */
|
|
|
|
static PHP_FUNCTION(json_encode)
|
|
|
|
{
|
|
|
|
zval *parameter;
|
|
|
|
smart_str buf = {0};
|
2014-08-25 17:24:55 +00:00
|
|
|
zend_long options = 0;
|
2014-11-25 20:36:41 +00:00
|
|
|
zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;
|
2009-05-31 01:44:07 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ll", ¶meter, &options, &depth) == FAILURE) {
|
2009-05-31 01:44:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-21 08:09:02 +00:00
|
|
|
JSON_G(error_code) = PHP_JSON_ERROR_NONE;
|
|
|
|
|
2015-02-09 10:06:02 +00:00
|
|
|
JSON_G(encode_max_depth) = (int)depth;
|
2012-07-24 11:15:16 +00:00
|
|
|
|
2015-02-09 10:06:02 +00:00
|
|
|
php_json_encode(&buf, parameter, (int)options);
|
2009-05-31 01:44:07 +00:00
|
|
|
|
2012-06-23 18:46:27 +00:00
|
|
|
if (JSON_G(error_code) != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
|
2014-04-23 19:44:26 +00:00
|
|
|
smart_str_free(&buf);
|
2012-04-02 01:46:18 +00:00
|
|
|
ZVAL_FALSE(return_value);
|
|
|
|
} else {
|
2014-04-23 19:44:26 +00:00
|
|
|
smart_str_0(&buf); /* copy? */
|
2014-09-19 11:41:01 +00:00
|
|
|
ZVAL_NEW_STR(return_value, buf.s);
|
2012-04-02 01:46:18 +00:00
|
|
|
}
|
2009-05-31 01:44:07 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto mixed json_decode(string json [, bool assoc [, long depth]])
|
|
|
|
Decodes the JSON representation into a PHP value */
|
|
|
|
static PHP_FUNCTION(json_decode)
|
|
|
|
{
|
|
|
|
char *str;
|
2014-08-27 17:25:28 +00:00
|
|
|
size_t str_len;
|
2009-05-31 01:44:07 +00:00
|
|
|
zend_bool assoc = 0; /* return JS objects as PHP objects by default */
|
2014-11-25 20:36:41 +00:00
|
|
|
zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;
|
2014-08-25 17:24:55 +00:00
|
|
|
zend_long options = 0;
|
2009-05-31 01:44:07 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|bll", &str, &str_len, &assoc, &depth, &options) == FAILURE) {
|
2009-05-31 01:44:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-06-01 09:44:38 +00:00
|
|
|
JSON_G(error_code) = 0;
|
|
|
|
|
2009-05-31 01:44:07 +00:00
|
|
|
if (!str_len) {
|
2015-02-02 11:07:34 +00:00
|
|
|
JSON_G(error_code) = PHP_JSON_ERROR_SYNTAX;
|
2009-05-31 01:44:07 +00:00
|
|
|
RETURN_NULL();
|
|
|
|
}
|
|
|
|
|
2010-05-21 22:59:58 +00:00
|
|
|
/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
|
|
|
|
if (assoc) {
|
|
|
|
options |= PHP_JSON_OBJECT_AS_ARRAY;
|
|
|
|
} else {
|
|
|
|
options &= ~PHP_JSON_OBJECT_AS_ARRAY;
|
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
php_json_decode_ex(return_value, str, str_len, options, depth);
|
2009-05-31 01:44:07 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2008-12-19 02:00:57 +00:00
|
|
|
/* {{{ proto int json_last_error()
|
2012-06-28 18:09:47 +00:00
|
|
|
Returns the error code of the last json_encode() or json_decode() call. */
|
2008-12-19 02:00:57 +00:00
|
|
|
static PHP_FUNCTION(json_last_error)
|
|
|
|
{
|
2012-06-28 18:09:47 +00:00
|
|
|
if (zend_parse_parameters_none() == FAILURE) {
|
2008-12-19 02:00:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 17:24:55 +00:00
|
|
|
RETURN_LONG(JSON_G(error_code));
|
2012-06-28 18:09:47 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto string json_last_error_msg()
|
|
|
|
Returns the error string of the last json_encode() or json_decode() call. */
|
|
|
|
static PHP_FUNCTION(json_last_error_msg)
|
|
|
|
{
|
|
|
|
if (zend_parse_parameters_none() == FAILURE) {
|
|
|
|
return;
|
2012-06-27 10:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(JSON_G(error_code)) {
|
|
|
|
case PHP_JSON_ERROR_NONE:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("No error");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_DEPTH:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Maximum stack depth exceeded");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_STATE_MISMATCH:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("State mismatch (invalid or malformed JSON)");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_CTRL_CHAR:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Control character error, possibly incorrectly encoded");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_SYNTAX:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Syntax error");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_UTF8:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Malformed UTF-8 characters, possibly incorrectly encoded");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_RECURSION:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Recursion detected");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_INF_OR_NAN:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Inf and NaN cannot be JSON encoded");
|
2012-06-27 10:19:41 +00:00
|
|
|
case PHP_JSON_ERROR_UNSUPPORTED_TYPE:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Type is not supported");
|
2015-06-21 14:30:33 +00:00
|
|
|
case PHP_JSON_ERROR_INVALID_PROPERTY_NAME:
|
|
|
|
RETURN_STRING("The decoded property name is invalid");
|
2015-06-28 16:16:12 +00:00
|
|
|
case PHP_JSON_ERROR_UTF16:
|
|
|
|
RETURN_STRING("Single unpaired UTF-16 surrogate in unicode escape");
|
2012-06-27 10:19:41 +00:00
|
|
|
default:
|
2014-04-23 19:44:26 +00:00
|
|
|
RETURN_STRING("Unknown error");
|
2012-06-27 10:19:41 +00:00
|
|
|
}
|
2012-06-28 18:09:47 +00:00
|
|
|
|
2008-12-19 02:00:57 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2006-05-05 15:49:42 +00:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
2009-05-31 01:44:07 +00:00
|
|
|
* vim600: noet sw=4 ts=4 fdm=marker
|
2006-05-05 15:49:42 +00:00
|
|
|
* vim<600: noet sw=4 ts=4
|
|
|
|
*/
|