#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

#141 in Encoding

Download history 16805/week @ 2024-08-17 17595/week @ 2024-08-24 22130/week @ 2024-08-31 20419/week @ 2024-09-07 19933/week @ 2024-09-14 20024/week @ 2024-09-21 19713/week @ 2024-09-28 14416/week @ 2024-10-05 28359/week @ 2024-10-12 26842/week @ 2024-10-19 17575/week @ 2024-10-26 14137/week @ 2024-11-02 14482/week @ 2024-11-09 10962/week @ 2024-11-16 12993/week @ 2024-11-23 18149/week @ 2024-11-30

59,043 downloads per month
Used in 185 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
~43K SLoC