From add107bee28fe4e3c18610fbafd6ec777d31525f Mon Sep 17 00:00:00 2001 From: Boyu Yang Date: Wed, 20 Mar 2024 11:34:10 +0800 Subject: [PATCH] fix: empty params shouldn't represent as null --- src/components/bitcoin_client.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/bitcoin_client.rs b/src/components/bitcoin_client.rs index 6758bf2..0fb2da3 100644 --- a/src/components/bitcoin_client.rs +++ b/src/components/bitcoin_client.rs @@ -30,14 +30,19 @@ impl Clone for BitcoinClient { } } +#[derive(Serialize, Clone, Copy)] +struct ZeroElemTuple(); + // ### Warning // // If parameters contain only one parameter: // - `serde_json::to_value(($($arg,)+))` // - `serde_json::to_value(($($arg),+))` // are different. +// +// Ref: https://github.com/serde-rs/serde/issues/1309 macro_rules! serialize_parameters { - () => ( serde_json::Value::Null ); + () => ( serde_json::to_value(ZeroElemTuple())?); ($($arg:ident),+) => ( serde_json::to_value(($($arg,)+))?) }