diff options
Diffstat (limited to 'ext/json/json_encoder.c')
-rw-r--r-- | ext/json/json_encoder.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index 92e4a10933..f608936349 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -36,29 +36,10 @@ static int php_json_escape_string( static int php_json_determine_array_type(zval *val) /* {{{ */ { - int i; - HashTable *myht = Z_ARRVAL_P(val); - - i = myht ? zend_hash_num_elements(myht) : 0; - if (i > 0) { - zend_string *key; - zend_ulong index, idx; + zend_array *myht = Z_ARRVAL_P(val); - if (HT_IS_PACKED(myht) && HT_IS_WITHOUT_HOLES(myht)) { - return PHP_JSON_OUTPUT_ARRAY; - } - - idx = 0; - ZEND_HASH_FOREACH_KEY(myht, index, key) { - if (key) { - return PHP_JSON_OUTPUT_OBJECT; - } else { - if (index != idx) { - return PHP_JSON_OUTPUT_OBJECT; - } - } - idx++; - } ZEND_HASH_FOREACH_END(); + if (myht) { + return zend_array_is_list(myht) ? PHP_JSON_OUTPUT_ARRAY : PHP_JSON_OUTPUT_OBJECT; } return PHP_JSON_OUTPUT_ARRAY; |