macro_rules! deserialize_with_root {
($root:tt : $inner:ty) => { ... };
}Expand description
Generates a custom SerDe Deseralize implementation that adds an
alternate root key to a Struct during deserialization.
ยงExample
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_struct_wrapper;
#[derive(Deserialize)]
#[serde(remote = "Self")]
pub struct Point {
pub x: i32,
pub y: i32,
}
deserialize_with_root!("point": Point);The above will deserialize a JSON structure like the following:
{
"point": {
"x": 1,
"y": 2
}
}