aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/json_dumper.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2023-08-25 22:00:01 +0100
committerJoão Valverde <j@v6e.pt>2023-08-27 01:07:21 +0000
commit79b97ddc6fd47ae52c0edc3a07ec0a44a1b56317 (patch)
treead0671a76a1bf4dddda908ed23cb7dbebadb5c76 /wsutil/json_dumper.c
parent6719e6a4916afdb6f37394b0066245e7c8f75f04 (diff)
wsutil: Fix JSON indentation when ending nested element
Add back the logic to indent the object or array closing element. It seems that it was unintentionally removed in commit ff9e2494a194a2a7d3c0538d6ca8eb3b0a7f6058.
Diffstat (limited to 'wsutil/json_dumper.c')
-rw-r--r--wsutil/json_dumper.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/wsutil/json_dumper.c b/wsutil/json_dumper.c
index 7466026803..75d016ca54 100644
--- a/wsutil/json_dumper.c
+++ b/wsutil/json_dumper.c
@@ -388,6 +388,11 @@ json_dumper_end_nested_element(json_dumper *dumper, enum json_dumper_element_typ
return FALSE;
}
+ // if the object/array was non-empty, add a newline and indentation.
+ if (dumper->state[dumper->current_depth]) {
+ print_newline_indent(dumper, dumper->current_depth - 1);
+ }
+
switch (type) {
case JSON_DUMPER_TYPE_OBJECT:
jd_putc(dumper, '}');