#named-fields #serialization #deserialize #array #structs #tuple #values

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

#139 in Encoding

Download history 19557/week @ 2024-09-16 19954/week @ 2024-09-23 19805/week @ 2024-09-30 15057/week @ 2024-10-07 28465/week @ 2024-10-14 26479/week @ 2024-10-21 17584/week @ 2024-10-28 14098/week @ 2024-11-04 13946/week @ 2024-11-11 11308/week @ 2024-11-18 14122/week @ 2024-11-25 17484/week @ 2024-12-02 19958/week @ 2024-12-09 17074/week @ 2024-12-16 11197/week @ 2024-12-23 8369/week @ 2024-12-30

57,513 downloads per month
Used in 186 crates (39 directly)

MIT license

15KB
369 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

~2MB
~42K SLoC