summaryrefslogtreecommitdiff
path: root/src/json/print.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/json/print.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/json/print.c b/src/json/print.c
index 97ccce8..9f2931f 100644
--- a/src/json/print.c
+++ b/src/json/print.c
@@ -68,7 +68,7 @@ static bool json_print_long_array(const tagdata_t *data, const stream_t *stream)
}
static bool json_print_string(const tagdata_t *data, const stream_t *stream) {
- if (data->string.size > 1) {
+ if (data->string.size > 0) {
if (printi(stream, 0, "\"%.*s\"", data->string.size, data->string.data) == false)
return false;
} else {
@@ -81,10 +81,14 @@ static bool json_print_string(const tagdata_t *data, const stream_t *stream) {
static bool json_print_compound(const tagdata_t *data, const stream_t *stream, int depth) {
if (printi(stream, 0, "{\n") == false)
return false;
- for (int32_t i = 0; i < data->compound.size; i++) {
- if (i != 0 && printi(stream, 0, ",\n") == false)
+ bool first = true;
+ for (uint32_t i = 0; i < data->compound.capacity; i++) {
+ if (data->compound.entries[i].name == NULL)
+ continue;
+ if (!first && printi(stream, 0, ",\n") == false)
return false;
- if (json_print_impl(&data->compound.tags[i], stream, depth + 1) == false)
+ first = false;
+ if (json_print_impl(&data->compound.entries[i], stream, depth + 1) == false)
return false;
}
if (printi(stream, 0, "\n") == false || printi(stream, depth, "}") == false)