#define PHP_JSON_HEX_QUOT (1<<3)
#define PHP_JSON_FORCE_OBJECT (1<<4)
+#define PHP_JSON_OUTPUT_ARRAY 0
+#define PHP_JSON_OUTPUT_OBJECT 1
+
ZEND_DECLARE_MODULE_GLOBALS(json)
/* {{{ arginfo */
}
}
- return 0;
+ return PHP_JSON_OUTPUT_ARRAY;
}
/* }}} */
if (Z_TYPE_PP(val) == IS_ARRAY) {
myht = HASH_OF(*val);
- r = (options & PHP_JSON_FORCE_OBJECT) ? 1 : json_determine_array_type(val TSRMLS_CC);
+ r = (options & PHP_JSON_FORCE_OBJECT) ? PHP_JSON_OUTPUT_OBJECT : json_determine_array_type(val TSRMLS_CC);
} else {
myht = Z_OBJPROP_PP(val);
- r = 1;
+ r = PHP_JSON_OUTPUT_OBJECT;
}
if (myht && myht->nApplyCount > 1) {
return;
}
- if (r == 0) {
+ if (r == PHP_JSON_OUTPUT_ARRAY) {
smart_str_appendc(buf, '[');
} else {
smart_str_appendc(buf, '{');
tmp_ht->nApplyCount++;
}
- if (r == 0) {
+ if (r == PHP_JSON_OUTPUT_ARRAY) {
if (need_comma) {
smart_str_appendc(buf, ',');
} else {
}
json_encode_r(buf, *data, options TSRMLS_CC);
- } else if (r == 1) {
+ } else if (r == PHP_JSON_OUTPUT_OBJECT) {
if (i == HASH_KEY_IS_STRING || i == HASH_KEY_IS_UNICODE) {
if (key.s[0] == '\0' && Z_TYPE_PP(val) == IS_OBJECT) {
/* Skip protected and private members. */
}
}
- if (r == 0) {
+ if (r == PHP_JSON_OUTPUT_ARRAY) {
smart_str_appendc(buf, ']');
} else {
smart_str_appendc(buf, '}');