Skip to content

Commit 356bb73

Browse files
committed
log/jsonrpc: getlog was returning invalid JSON.
A mixup between object and array notation in the getlog response was resulting in invalid JSON.
1 parent 5b3bde7 commit 356bb73

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

daemon/jsonrpc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ struct log_info {
7171
static void add_skipped(struct log_info *info)
7272
{
7373
if (info->num_skipped) {
74-
json_array_start(info->response, NULL);
74+
json_object_start(info->response, NULL);
7575
json_add_string(info->response, "type", "SKIPPED");
7676
json_add_num(info->response, "num_skipped", info->num_skipped);
77-
json_array_end(info->response);
77+
json_object_end(info->response);
7878
info->num_skipped = 0;
7979
}
8080
}
@@ -106,7 +106,7 @@ static void log_to_json(unsigned int skipped,
106106

107107
add_skipped(info);
108108

109-
json_array_start(info->response, NULL);
109+
json_object_start(info->response, NULL);
110110
json_add_string(info->response, "type",
111111
level == LOG_BROKEN ? "BROKEN"
112112
: level == LOG_UNUSUAL ? "UNUSUAL"
@@ -126,7 +126,7 @@ static void log_to_json(unsigned int skipped,
126126
} else
127127
json_add_string(info->response, "log", log);
128128

129-
json_array_end(info->response);
129+
json_object_end(info->response);
130130
}
131131

132132
static void json_getlog(struct command *cmd,
@@ -160,9 +160,9 @@ static void json_getlog(struct command *cmd,
160160
json_add_time(info.response, "creation_time", log_init_time(lr)->ts);
161161
json_add_num(info.response, "bytes_used", (unsigned int)log_used(lr));
162162
json_add_num(info.response, "bytes_max", (unsigned int)log_max_mem(lr));
163-
json_object_start(info.response, "log");
163+
json_array_start(info.response, "log");
164164
log_each_line(lr, log_to_json, &info);
165-
json_object_end(info.response);
165+
json_array_end(info.response);
166166
json_object_end(info.response);
167167
command_success(cmd, info.response);
168168
}

0 commit comments

Comments
 (0)