Let's say i have the struct:
pub struct MyStruct {
one: u32,
two: bool,
}
I would like to serialize this struct into JSON where the end result would include a "type" field as follows:
{'type': 'MyStruct', 'one': 1, 'two': true}
Would that be possible with serde_json?
alice
2
#[derive(Serialize)]
#[serde(tag = "type")]
pub struct MyStruct {
one: u32,
two: bool,
}
2 Likes
system
Closed
3
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.