not-fl3 / nanoserde

Serialisation library with zero dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enum JSON serialization is wrong

Gelbpunkt opened this issue · comments

#[derive(DeJson, SerJson, Debug, PartialEq, Copy, Clone)]
pub enum SendMode {
    #[nserde(rename = "round-robin")]
    RoundRobin,
    #[nserde(rename = "by-charid")]
    ByCharId,
    #[nserde(rename = "by-msgid")]
    ByMsgId,
    #[nserde(rename = "by-worker")]
    ByWorker,
    #[nserde(rename = "proxy-default")]
    Default,
}

...

let mode = SendMode::RoundRobin;
SerJson::serialize_json(&mode);
// {"RoundRobin":[]}
// serde_json makes this "round-robin" (a string including the quotes)

Deserializing is the same: Json Deserialize error: Unexpected token Str expected { , line:1 col:23