How can I deserialize an enum when the case doesn't match?
问题 I have a JSON structure that looks like this: { "type": "suite", "event": "started", "test_count": 1 } I want to deserialize into these structs: #[derive(Debug, Deserialize)] enum ResultType { Suite, Test, } #[derive(Debug, Deserialize)] enum ResultEvent { Started, Failed, Ok, } #[derive(Debug, Deserialize)] struct JsonResult { #[serde(rename(deserialize = "type"))] test_type: ResultType, event: ResultEvent, test_count: Option<u32>, } I can't find a way to make serde_json use the correct case