#serde #tuple #tuples #array #named

serde_tuple

De/serialize structs with named fields as array of values

10 unstable releases (4 breaking)

0.5.0 Mar 20, 2020
0.4.0 Jan 7, 2020
0.3.0 Jan 1, 2020
0.2.5 Apr 24, 2019
0.1.2 Jan 30, 2019
Download history 5494/week @ 2021-09-26 3691/week @ 2021-10-03 3754/week @ 2021-10-10 3813/week @ 2021-10-17 2933/week @ 2021-10-24 2133/week @ 2021-10-31 2414/week @ 2021-11-07 2224/week @ 2021-11-14 2104/week @ 2021-11-21 2482/week @ 2021-11-28 3687/week @ 2021-12-05 5688/week @ 2021-12-12 2867/week @ 2021-12-19 1738/week @ 2021-12-26 4163/week @ 2022-01-02 4260/week @ 2022-01-09

13,419 downloads per month
Used in 23 crates (8 directly)

MIT license

14KB
368 lines

serde_tuple

De/serialize structs with named fields as array of values.

See: https://github.com/dtolnay/request-for-implementation/issues/3

Usage

use serde_tuple::*;

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct Foo<'a> {
    bar: &'a str,
    baz: i32
}

let foo = Foo { bar: "Yes", baz: 22 };
let json = serde_json::to_string(&foo).unwrap();
println!("{}", &json);
// # => ["Yes",22]

License: MIT


lib.rs:

Derive macros to serialize and deserialize struct with named fields as an array of values

Examples

use serde_tuple::*;

#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct Foo<'a> {
    bar: &'a str,
    baz: i32
}
let foo = Foo { bar: "Yes", baz: 22 };
let json = serde_json::to_string(&foo).unwrap();
println!("{}", &json);
// # => ["Yes",22]

Dependencies

~0.4–1MB
~23K SLoC

u^