mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 07:34:21 +01:00
lightningd: have json_stream_success start the "result" object.
"result" should always be an object (so that we can add new fields), so make that implicit in json_stream_success. This makes our primitives well-formed: we previously used NULL as our fieldname when calling the first json_object_start, which is a hack since we're actually in an object and the fieldname is 'result' (which was already written by json_object_start). There were only two cases which didn't do this: 1. dev-memdump returned an array. No API guarantees on this. 2. shutdown returned a string. I temporarily made shutdown return an empty object, which shouldn't break anything, but I want to fix that later anyway. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1066,7 +1066,6 @@ static struct command_result *json_listconfigs(struct command *cmd,
|
||||
|
||||
if (!configtok) {
|
||||
response = json_stream_success(cmd);
|
||||
json_object_start(response, NULL);
|
||||
json_add_string(response, "# version", version());
|
||||
}
|
||||
|
||||
@@ -1091,10 +1090,8 @@ static struct command_result *json_listconfigs(struct command *cmd,
|
||||
name + 1, len - 1))
|
||||
continue;
|
||||
|
||||
if (!response) {
|
||||
if (!response)
|
||||
response = json_stream_success(cmd);
|
||||
json_object_start(response, NULL);
|
||||
}
|
||||
add_config(cmd->ld, response, &opt_table[i],
|
||||
name+1, len-1);
|
||||
}
|
||||
@@ -1106,7 +1103,6 @@ static struct command_result *json_listconfigs(struct command *cmd,
|
||||
json_tok_full_len(configtok),
|
||||
json_tok_full(buffer, configtok));
|
||||
}
|
||||
json_object_end(response);
|
||||
return command_success(cmd, response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user