We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This would be valuable to support if possible. Serialization already works but deserialization does not.
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; #[derive(Serialize, Deserialize, Debug)] struct Data { id: i32, #[serde(flatten)] payload: Enum, } #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "type")] enum Enum { A(A), B(B), } #[derive(Serialize, Deserialize, Debug)] struct A { field_a: i32, } #[derive(Serialize, Deserialize, Debug)] struct B { field_b: i32, } fn main() { let data = Data { id: 0, payload: Enum::A(A { field_a: 0 }), }; let j = serde_json::to_string(&data).unwrap(); println!("{}", j); println!("{}", serde_json::from_str::<Data>(&j).unwrap_err()); }
{"id":0,"type":"A","field_a":0} can only flatten structs and maps at line 1 column 31
The text was updated successfully, but these errors were encountered:
@mammothbane @Nemikolh @weiwei-lin @georgemarshall @PlasmaPower @jplatte this is now supported in 1.0.46!
Sorry, something went wrong.
dtolnay
No branches or pull requests
This would be valuable to support if possible. Serialization already works but deserialization does not.
The text was updated successfully, but these errors were encountered: