mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 10:38:20 +00:00
Return null instead of skipping field on empty success response
This commit is contained in:
parent
c7e9e9dfee
commit
e93c1cc438
1 changed files with 3 additions and 2 deletions
|
@ -45,8 +45,9 @@ struct RpcRequest {
|
|||
struct RpcResponse {
|
||||
id: i64,
|
||||
jsonrpc: String,
|
||||
// Note: this Option<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<Box<RawValue>>,
|
||||
result: Option<Option<Box<RawValue>>>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
error: Option<RpcErrorObject>,
|
||||
}
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue