https://github.com/daboross/serde-tuple-vec-map
Deserialize objects/maps into Vecs of key/value tuples.
https://github.com/daboross/serde-tuple-vec-map
Last synced: 11 months ago
JSON representation
Deserialize objects/maps into Vecs of key/value tuples.
- Host: GitHub
- URL: https://github.com/daboross/serde-tuple-vec-map
- Owner: daboross
- License: mit
- Created: 2017-03-28T07:26:51.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-02-10T02:36:50.000Z (over 3 years ago)
- Last Synced: 2025-07-27T20:04:22.748Z (12 months ago)
- Language: Rust
- Size: 28.3 KB
- Stars: 18
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
serde-tuple-vec-map
================
[![Build Status][travis-image]][travis-builds]
[![crates.io version badge][cratesio-badge]][cratesio-page]
Deserialize maps or JSON objects in [serde] to a vec of tuples rather than a
HashMap for when you're only ever going to iterate over the result.
Usage:
```rust
// replace this:
#[derive(Serialize, Deserialize)]
struct MyStuff {
data: HashMap,
}
// with this:
#[derive(Serialize, Deserialize)]
struct MyStuff {
#[serde(with = "tuple_vec_map")]
data: Vec<(KeyType, ValueType)>,
}
```
The serialized format remains exactly the same, the only difference is in how
the data is decoded in Rust.
serde-tuple-vec-map supports no_std builds by using `Vec` defined in the `alloc`
crate. If you're on rust 1.36.0 or newer, you can enable this with
`default-features=false`:
```toml
[dependencies.serde-tuple-vec-map]
version = "1"
default-features = false
```
Note: This crate is complete, and passively maintained. It depends solely on
`serde` and features present in stable rust. The minimum supported rust
version 1.13.0 when using default features, and 1.36.0 for
`default-features = false`.
Full usage example in [`tests/integration.rs`][example], documentation at
https://docs.rs/serde-tuple-vec-map.
[travis-image]: https://travis-ci.org/daboross/serde-tuple-vec-map.svg?branch=master
[travis-builds]: https://travis-ci.org/daboross/serde-tuple-vec-map
[serde]: https://github.com/serde-rs/serde/
[cratesio-badge]: http://meritbadge.herokuapp.com/serde-tuple-vec-map
[cratesio-page]: https://crates.io/crates/serde-tuple-vec-map
[example]: https://github.com/daboross/serde-tuple-vec-map/blob/1.0.1/tests/integration.rs