serde_tuple icon indicating copy to clipboard operation
serde_tuple copied to clipboard

Enum support

Open UnlimitedCookies opened this issue 1 year ago • 1 comments

Hi, it would be awesome to be able to also tuple serialize enum with fields in to json lists/tuples, where the first field is the name of the variant.

example:

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Action {
    Rule{pos: u16, rule_index: u16},
    Cut{start_index: u16, end_index: u16}
}

currently (de)serializes to {"rule":{"pos":0,"rule_index":0}} but I'd much rather have ["rule",0,0].

UnlimitedCookies avatar Oct 23 '24 04:10 UnlimitedCookies

I think this would work and would probably be a good addition, if you would like to work on it! Currently this library only works with structs with named fields.

kardeiz avatar Nov 14 '24 02:11 kardeiz