serde-rs / serde

Serialization framework for Rust
https://serde.rs/
Apache License 2.0
9.06k stars 767 forks source link

Rename fields at runtime #2731

Open pronebird opened 5 months ago

pronebird commented 5 months ago

I'd love to see configurable serializers and deserializers that aren't baked into the struct.

I have a few structs that are shared between Rust crates, which typically prefer snake_case and interop with other languages that prefer camelCase.

Languages like Swift use separate encoders that can be configured to modify the key coding strategy without modifying the struct or duplicating it. I think it would be great to have something similar in serde.