Expand description
Deserializing maps to tuple-vecs.
To use, just include a Vec<(String, ...)>
in your struct instead of a HashMap<String, ...>
and tag it with #[serde(with = "tuple_vec_map")
:
extern crate tuple_vec_map;
#[derive(Serialize, Deserialize)]
struct SomeData {
other_stuff: u32,
#[serde(with = "tuple_vec_map")]
inner_data: Vec<(String, String)>,
}
That’s it! Now your structure accepts an inner_data Map or JSON Object, and instead of making a HashMap for the data, the key/value pairs are simply collected into a Vec.
§Features
To use without std
, depend on serde-tuple-vec-map
with default-features = false
. This will still
depend on the alloc
crate, and requires Rust 1.36.0 or newer.
Functions§
- Deserialize to a
Vec<(K, V)>
as if it were aHashMap<K, V>
. - Serialize an array of
(K, V)
pairs as if it were aHashMap<K, V>
.