From e93c1cc43858d35c7fd835a56d71b769bd79f5ec Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Sun, 29 Oct 2023 23:23:50 +0100 Subject: [PATCH] Return null instead of skipping field on empty success response --- src/web/rpc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/web/rpc.rs b/src/web/rpc.rs index 372d335..009a964 100644 --- a/src/web/rpc.rs +++ b/src/web/rpc.rs @@ -45,8 +45,9 @@ struct RpcRequest { struct RpcResponse { id: i64, jsonrpc: String, + // Note: this Option> is for distinguishing between success without a result (null) and and error where the field is skipped #[serde(skip_serializing_if = "Option::is_none")] - result: Option>, + result: Option>>, #[serde(skip_serializing_if = "Option::is_none")] error: Option, } @@ -116,7 +117,7 @@ async fn api_handler( Ok(res) => Json(RpcResponse { id: req.id, jsonrpc: req.jsonrpc, - result: res, + result: Some(res), error: None, }), Err(err) => Json(RpcResponse {