summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2014-12-12 19:52:45 +0000
committerJakub Zelenka <bukka@php.net>2014-12-12 19:52:45 +0000
commit9e5f687957d532912d062f11dc4f5b2a368e5c4b (patch)
tree6129cbaea085087a86cfb599f216264ebbd1c7aa /ext/json
parentc6d0905158fcf415f71c5c338f76d78030e746e4 (diff)
downloadphp-git-9e5f687957d532912d062f11dc4f5b2a368e5c4b.tar.gz
Fix json object decoding
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/json_parser.y13
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y
index 6b40c259f3..dbacc3d483 100644
--- a/ext/json/json_parser.y
+++ b/ext/json/json_parser.y
@@ -176,7 +176,11 @@ php_json_error_code php_json_parser_error_code(php_json_parser *parser)
void php_json_parser_object_init(php_json_parser *parser, zval *object)
{
TSRMLS_FETCH_FROM_CTX(parser->zts_ctx);
- object_init(object);
+ if (parser->scanner.options & PHP_JSON_OBJECT_AS_ARRAY) {
+ array_init(object);
+ } else {
+ object_init(object);
+ }
}
void php_json_parser_object_update(php_json_parser *parser, zval *object, zval *zkey, zval *zvalue)
@@ -190,18 +194,17 @@ void php_json_parser_object_update(php_json_parser *parser, zval *object, zval *
} else {
if (key_len == 0) {
key = "_empty_";
- key_len = sizeof("_empty_");
+ key_len = sizeof("_empty_") - 1;
}
add_property_zval_ex(object, key, key_len, zvalue TSRMLS_CC);
- /*
+
if (Z_REFCOUNTED_P(zvalue)) {
Z_DELREF_P(zvalue);
}
- */
}
+ zval_dtor(zkey);
}
-
void php_json_parser_array_init(zval *array)
{
array_init(array);