#value #serde #deserialize-tuple #serde-tuple

serde_tuple

De/serialize structs with named fields as array of values

12 releases (2 stable)

1.1.0 Nov 14, 2024
1.0.0 Sep 14, 2024
0.5.0 Mar 20, 2020
0.4.0 Jan 7, 2020
0.1.2 Jan 30, 2019

#107 in Encoding

Download history 18155/week @ 2025-01-04 14227/week @ 2025-01-11 16036/week @ 2025-01-18 17263/week @ 2025-01-25 19293/week @ 2025-02-01 20039/week @ 2025-02-08 18216/week @ 2025-02-15 19823/week @ 2025-02-22 15056/week @ 2025-03-01 15667/week @ 2025-03-08 16414/week @ 2025-03-15 16732/week @ 2025-03-22 15079/week @ 2025-03-29 18090/week @ 2025-04-05 14946/week @ 2025-04-12 18648/week @ 2025-04-19

69,538 downloads per month
Used in 231 crates (40 directly)

MIT license

15KB
369 lines

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]

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

Dependencies

~0.3–0.9MB
~21K SLoC