I'd like to use this crate's serde_value::Value as a more generic version of serde_json::Value.
My use case is an HTTP API where the success response body is defined as such:
#[derive(serde::Serialize)]
struct SuccessBody {
data: serde_json::Value,
}
impl SuccessBody {
pub fn new(data: impl Into<serde_json::Value>) -> Self {
let data = data.into();
Self { data }
}
}
Since most (all?) serialize_* are infallible, e.g:
|
fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error> { |
|
Ok(Value::Bool(v)) |
|
} |
|
|
|
fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error> { |
|
Ok(Value::I8(v)) |
|
} |
|
|
|
fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error> { |
|
Ok(Value::I16(v)) |
|
} |
this should be trivial to implement.
I can submit a PR if you believe this is worth implementing.
I'd like to use this crate's
serde_value::Valueas a more generic version ofserde_json::Value.My use case is an HTTP API where the success response body is defined as such:
Since most (all?)
serialize_*are infallible, e.g:serde-value/src/ser.rs
Lines 77 to 87 in 47190f5
this should be trivial to implement.
I can submit a PR if you believe this is worth implementing.