#serde #tuple #serialization

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

#212 in Encoding

Download history 14139/week @ 2023-02-13 15117/week @ 2023-02-20 12992/week @ 2023-02-27 15737/week @ 2023-03-06 17007/week @ 2023-03-13 14574/week @ 2023-03-20 15108/week @ 2023-03-27 12290/week @ 2023-04-03 11497/week @ 2023-04-10 18041/week @ 2023-04-17 13969/week @ 2023-04-24 12433/week @ 2023-05-01 15858/week @ 2023-05-08 14070/week @ 2023-05-15 15709/week @ 2023-05-22 14692/week @ 2023-05-29

60,648 downloads per month
Used in 170 crates (26 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.6–1.1MB
~27K SLoC