diff --git a/lib/json_print.c b/lib/json_print.c index e3da1bdf..b507b14b 100644 --- a/lib/json_print.c +++ b/lib/json_print.c @@ -89,9 +89,7 @@ void open_json_array(enum output_type type, const char *str) void close_json_array(enum output_type type, const char *str) { if (_IS_JSON_CONTEXT(type)) { - jsonw_pretty(_jw, false); jsonw_end_array(_jw); - jsonw_pretty(_jw, true); } else if (_IS_FP_CONTEXT(type)) { printf("%s", str); } diff --git a/lib/json_writer.c b/lib/json_writer.c index f3eeaf7b..0d910dc0 100644 --- a/lib/json_writer.c +++ b/lib/json_writer.c @@ -180,10 +180,15 @@ void jsonw_end_object(json_writer_t *self) void jsonw_start_array(json_writer_t *self) { jsonw_begin(self, '['); + if (self->pretty) + putc(' ', self->out); } void jsonw_end_array(json_writer_t *self) { + if (self->pretty && self->sep) + putc(' ', self->out); + self->sep = '\0'; jsonw_end(self, ']'); }