From d86ad15b538f5b3ca0439c1c77fe7abb55cd0eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corn=C3=A9=20Plooy?= Date: Tue, 27 Feb 2018 14:42:51 +0100 Subject: [PATCH] json-rpc: translate NULL into "null" instead of "(null)". --- lightningd/jsonrpc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index c1bab59ec..86f158c8e 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -290,6 +290,12 @@ static void connection_complete_error(struct json_connection *jcon, else data_str = ""; + /* + tal_fmt translates NULL into "(null)", which is not valid JSON. + Prevent this by pre-emptively translating NULL into "null". + */ + if(id == NULL) id = "null"; + json_done(jcon, cmd, take(tal_fmt(tmpctx, "{ \"jsonrpc\": \"2.0\", " " \"error\" : "