diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c5d0d91d..c189d8c22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added +- JSON API: use `\n\n` to terminate responses, for simplified parsing. + ### Changed ### Deprecated @@ -22,6 +24,7 @@ changes. - JSON API: uppercase invoices now parsed correctly (broken in 0.6.2). - pylightning: handle multiple simultanous RPC replies reliably. + ### Security diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 4a78e812a..c7cabe1d5 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -363,7 +363,7 @@ void command_success(struct command *cmd, struct json_stream *result) assert(cmd); assert(cmd->have_json_stream); if (cmd->jcon) - jcon_append(cmd->jcon, " }\n"); + jcon_append(cmd->jcon, " }\n\n"); if (cmd->ok) *(cmd->ok) = true; tal_free(cmd); @@ -375,7 +375,7 @@ void command_failed(struct command *cmd, struct json_stream *result) assert(cmd->have_json_stream); /* Have to close error */ if (cmd->jcon) - jcon_append(cmd->jcon, " } }\n"); + jcon_append(cmd->jcon, " } }\n\n"); if (cmd->ok) *(cmd->ok) = false; tal_free(cmd); @@ -418,7 +418,7 @@ static void json_command_malformed(struct json_connection *jcon, jcon_append(jcon, tal_fmt(tmpctx, " \"error\" : " "{ \"code\" : %d," - " \"message\" : \"%s\" } }\n", + " \"message\" : \"%s\" } }\n\n", JSONRPC2_INVALID_REQUEST, error)); }