mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Add missing bits to php_json.h
This commit is contained in:
parent
e18dd67975
commit
a4e59c39a7
2 changed files with 20 additions and 16 deletions
|
@ -195,7 +195,7 @@ static PHP_FUNCTION(json_encode)
|
|||
zval *parameter;
|
||||
smart_str buf = {0};
|
||||
zend_long options = 0;
|
||||
zend_long depth = JSON_PARSER_DEFAULT_DEPTH;
|
||||
zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", ¶meter, &options, &depth) == FAILURE) {
|
||||
return;
|
||||
|
@ -224,7 +224,7 @@ static PHP_FUNCTION(json_decode)
|
|||
char *str;
|
||||
size_t str_len;
|
||||
zend_bool assoc = 0; /* return JS objects as PHP objects by default */
|
||||
zend_long depth = JSON_PARSER_DEFAULT_DEPTH;
|
||||
zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;
|
||||
zend_long options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bll", &str, &str_len, &assoc, &depth, &options) == FAILURE) {
|
||||
|
|
|
@ -37,20 +37,6 @@ extern zend_module_entry json_module_entry;
|
|||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(json)
|
||||
int encoder_depth;
|
||||
int error_code;
|
||||
int encode_max_depth;
|
||||
ZEND_END_MODULE_GLOBALS(json)
|
||||
|
||||
#ifdef ZTS
|
||||
# define JSON_G(v) TSRMG(json_globals_id, zend_json_globals *, v)
|
||||
#else
|
||||
# define JSON_G(v) (json_globals.v)
|
||||
#endif
|
||||
|
||||
PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC);
|
||||
PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth TSRMLS_DC);
|
||||
extern PHP_JSON_API zend_class_entry *php_json_serializable_ce;
|
||||
|
||||
/* error codes */
|
||||
|
@ -83,10 +69,28 @@ typedef enum {
|
|||
#define PHP_JSON_OUTPUT_ARRAY 0
|
||||
#define PHP_JSON_OUTPUT_OBJECT 1
|
||||
|
||||
/* default depth */
|
||||
#define PHP_JSON_PARSER_DEFAULT_DEPTH 512
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(json)
|
||||
int encoder_depth;
|
||||
int encode_max_depth;
|
||||
php_json_error_code error_code;
|
||||
ZEND_END_MODULE_GLOBALS(json)
|
||||
|
||||
#ifdef ZTS
|
||||
# define JSON_G(v) TSRMG(json_globals_id, zend_json_globals *, v)
|
||||
#else
|
||||
# define JSON_G(v) (json_globals.v)
|
||||
#endif
|
||||
|
||||
/* json_decode() options */
|
||||
#define PHP_JSON_OBJECT_AS_ARRAY (1<<0)
|
||||
#define PHP_JSON_BIGINT_AS_STRING (1<<1)
|
||||
|
||||
PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC);
|
||||
PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth TSRMLS_DC);
|
||||
|
||||
static inline void php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, zend_long depth TSRMLS_DC)
|
||||
{
|
||||
php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth TSRMLS_CC);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue