Serde, an equivalent third-party crate in Rust, supports a lot of customization which I find invaluable. It can (de)serialize values like this with ease:
{"type": "location", "value": {"latitude": 0, "longitude": 0}}
in a very small amount of code: #[derive(Serialize, Deserialize)]
#[serde(tag = "type", content = "value")]
#[serde(rename_all = "lowercase")]
enum Value {
Location { latitude: f64, longitude: f64 },
String(String),
...
}
Serde also supports customizing serialization on a per-field basis without having to implement the entire protocol, which is nice: #[derive(Deserialize, Serialize)]
struct Record {
#[serde(with = "chrono::serde::ts_seconds")]
updated: DateTime<Utc>
}
I really hope that Swift has better ways (like the above) to customize Codable in the future. I find myself implementing the protocol myself in 90% of cases, whereas I very rarely have to do that for Serde.