Last active
September 7, 2022 20:31
-
-
Save aletheia/90087978f6f3f9c2adcc3047349c7cab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Deserialize, Serialize)] | |
struct User { | |
customer_id: String, | |
senior_citizen: i32, | |
#[serde(default, rename = "churnProbability")] | |
churn_probability: Option<f64>, | |
#[serde(rename = "MonthlyCharges")] | |
monthly_charges: f64, | |
#[serde(rename = "TotalCharges")] | |
total_charges: f64, | |
is_male: i32, | |
is_partner: i32, | |
payment_method: i32, | |
// [...] other attributes | |
} | |
// Usage example. Let's say we've a serialized JSON in a serialized_user variable, then deserialization is as simple as | |
let mut user: User = serde_json::from_str(&serialized_user)?; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
done