Deserialize maps or JSON objects in serde to structs that implement the
FromKeyValue
trait.
```rust use serdekeyvaluevecmap::*;
struct SingleMeasurement { name: String, value: u32, }
impl KeyValueLike for SingleMeasurement { type Key = String; type Value = u32; fn fromkeyvalue(key: Self::Key, value: Self::Value) -> Self { Self { name: key, value } } fn key(&self) -> &Self::Key { &self.name } fn value(&self) -> &Self::Value { &self.value } }
let json = r#" { "temperature": 40, "pressure": 123 } "#;
struct Container {
#[serde(flatten)]
#[serde(with = "serdekeyvaluevecmap")]
measurements: Vec
let container: Container = serdejson::fromstr(json).unwrap();
println!("{:?}", container.measurements); ```