Open dmarcuse opened 5 years ago
Following up on https://github.com/serde-rs/serde/pull/1972#issuecomment-929907819
Has the moratorium on new attributes been lifted (or will it ever be)? If new attributes are accepted again, this branch [diff] would contain an implementation compatible with the current master
.
If compile time is still the biggest concern, maybe a solution is to feature gate (new) attributes.
For everyone else stumbling over this, while searching for a solution myself, I found serde_alias.
I would also love to have something like this. Have a config which uses kebab-case
and should support overriding from env vars. This is not possible with current options (as far as I can tell), unless I want to spend a large effort creating my own deserializer - which is a bit outside my time budget.
Are there any plans for this feature/a similar one? Or maybe some workarounds I could use in the meantime?
The
rename_all
attribute is very handy for cases where you have fields named in ways that don't follow Rust conventions. However, there are cases where you might want to support both ways - for example, loading data with support for both naming conventions, but preferring a different naming convention for saving that data later. I propose that analias_all
container attribute be added that functions similarly torename_all
, so that a struct like this......can be deserialized from JSON like this...
...but will still be serialized like this: