When streaming JSON normal values also have indent == 1.
For those however it is incorrect to close the stream.
Fixes #2644
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
(cherry picked from commit
5130ce8ee5b71c249e0c8bb7a4975dc8a48c64fa)
void ul_jsonwrt_close(struct ul_jsonwrt *fmt, int type)
{
- if (fmt->indent == 1) {
- fputs("\n}\n", fmt->out);
- fmt->indent--;
- fmt->after_close = 1;
- return;
- }
assert(fmt->indent > 0);
switch (type) {
fputc('\n', fmt->out);
ul_jsonwrt_indent(fmt);
fputs("}", fmt->out);
+ if (fmt->indent == 0)
+ fputs("\n", fmt->out);
break;
case UL_JSON_ARRAY:
fmt->indent--;