Open
Description
This is similar, but not quite the same as #497. In this case it is a normally tagged enum.
Rust playground example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4d9015b013535f143aa5b8ad829be43c
Code:
use serde_json::value::RawValue;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct RequestBody {
pub payload: Box<RawValue>,
}
#[derive(Serialize, Deserialize)]
#[serde(tag = "type")]
enum Incoming {
Request {
payload: Box<RawValue>,
},
}
fn main() {
let foo = Incoming::Request {
payload: serde_json::value::to_raw_value(&42).unwrap()
};
let txt = serde_json::to_string(&foo).unwrap();
let roundtrip: Incoming = serde_json::from_str(&txt).unwrap();
}
Metadata
Metadata
Assignees
Labels
No labels