I'm not sure if this is possible in serde, but it would be nice if json fields in camel case could be mapped to snake case rust field names, either explicitly via some macros or automatically by the deserializer. This way one could adhere to conventions in naming both on the frontend and backend (camel in json/JS, snake in Rust).
My apologies if this feature exists and I simply missed it, I'd appreciate some pointers.
You can use serde(rename_all = "camelCase") on a struct to map the fields this way.
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct Mandreyel {
aaa_aaa: u8, // deserializes from json "aaaAaa"
bbb_bbb: u8,
}
```
That is exactly what I'm looking for, thanks! :relaxed:
Most helpful comment
You can use
serde(rename_all = "camelCase")on a struct to map the fields this way.```