ulong index;
uint key_len;
HashPosition pos;
- int htlen = i;
- int wpos = 0;
+ int need_comma = 0;
zend_hash_internal_pointer_reset_ex(myht, &pos);
for (;; zend_hash_move_forward_ex(myht, &pos)) {
if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) == SUCCESS) {
if (r == 0) {
+ if (need_comma) {
+ smart_str_appendc(buf, ',');
+ } else {
+ need_comma = 1;
+ }
+
json_encode_r(buf, *data TSRMLS_CC);
} else if (r == 1) {
if (i == HASH_KEY_IS_STRING) {
continue;
}
+ if (need_comma) {
+ smart_str_appendc(buf, ',');
+ } else {
+ need_comma = 1;
+ }
+
json_escape_string(buf, key, key_len - 1 TSRMLS_CC);
smart_str_appendc(buf, ':');
json_encode_r(buf, *data TSRMLS_CC);
} else {
+ if (need_comma) {
+ smart_str_appendc(buf, ',');
+ } else {
+ need_comma = 1;
+ }
+
smart_str_appendc(buf, '"');
smart_str_append_long(buf, (long) index);
smart_str_appendc(buf, '"');
json_encode_r(buf, *data TSRMLS_CC);
}
}
-
- if (htlen > 1 && wpos++ < htlen - 1)
- {
- smart_str_appendc(buf, ',');
- }
}
}
}
<license>PHP 3.01</license>
<release>
<state>stable</state>
- <version>1.2.0</version>
- <date>2006-03-15</date>
+ <version>1.2.1</version>
+ <date>2006-03-18</date>
<notes>
- Complete rewrite using JSON_checker as the base for the parser. Implements the JSON specification. 3-8x faster on encodes and 1.2x-4x faster on decodes.
+ Fix PECL bug #7147 - rework handling of comma insertion while encoding.
+ Add tests to package.xml
</notes>
</release>
<configureoptions>
<file role="src" name="utf8_decode.h" />
<file role="src" name="utf8_to_utf16.c" />
<file role="src" name="utf8_to_utf16.h" />
+ <dir role="test" name="tests">
+ <file role="test" name="fail001.phpt" />
+ <file role="test" name="pass001.phpt" />
+ <file role="test" name="pass001.1.phpt" />
+ <file role="test" name="pass002.phpt" />
+ <file role="test" name="pass003.phpt" />
+ </dir>
</filelist>
<changelog>
<release>
Cleanup and TSRM performance fixes by rasmus.
</notes>
</release>
+ <release>
+ <state>stable</state>
+ <version>1.2.0</version>
+ <date>2006-03-15</date>
+ <notes>
+ Complete rewrite using JSON_checker as the base for the parser. Implements the JSON specification. 3-8x faster on encodes and 1.2x-4x faster on decodes.
+ </notes>
+ </release>
</changelog>
</package>
<!--