Closed orclev closed 4 months ago
Prefix is supported by using https://docs.rs/serde_with/3.8.1/serde_with/macro.with_prefix.html.
Suffix was previously requested in https://github.com/jonasbb/serde_with/issues/381 but there doesn't seem to be demand.
Ah nice, I had looked through the docs for flatten and didn't see any way to add a prefix, I didn't realize it was an entirely different attribute. Thanks.
In Java the Jackson serialization library has a feature similar to flatten which is the
@JsonUnwrapped
annotation. Unlike flatten however it supports a pair of optional parametersprefix
andsuffix
which are arbitraryString
values that will be prepended or appended respectively to the flattened fields names. This is very useful when you have multiple instances of some struct that you want to flatten but you want to avoid name collisions. It would be great if serde could support a similar prefix and suffix argument to flatten.