summaryrefslogtreecommitdiff
path: root/ext/json/json_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json/json_encoder.c')
-rw-r--r--ext/json/json_encoder.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c
index 2c3843fdd2..f128558fbb 100644
--- a/ext/json/json_encoder.c
+++ b/ext/json/json_encoder.c
@@ -189,8 +189,13 @@ static int php_json_encode_array(smart_str *buf, zval *val, int options, php_jso
php_json_pretty_print_char(buf, options, '\n');
php_json_pretty_print_indent(buf, options, encoder);
- php_json_escape_string(buf, ZSTR_VAL(key), ZSTR_LEN(key),
- options & ~PHP_JSON_NUMERIC_CHECK, encoder);
+ if (php_json_escape_string(buf, ZSTR_VAL(key), ZSTR_LEN(key),
+ options & ~PHP_JSON_NUMERIC_CHECK, encoder) == FAILURE &&
+ (options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR) &&
+ buf->s) {
+ ZSTR_LEN(buf->s) -= 4;
+ smart_str_appendl(buf, "\"\"", 2);
+ }
} else {
if (need_comma) {
smart_str_appendc(buf, ',');