serde-rs / serde

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

External tagging for unit-like enum variants #2701

Open JakkuSakura opened 4 months ago

JakkuSakura commented 4 months ago

I ran into this problem today. I have a source code and I try to add serde support to deal with external data.

// no #derive[serde::Deserialize]
enum Foo {
   A,
   B
}

But the data I got is

{ "A": {} }

Is there a way to represent things like #[serde(external_tagged)]? I can certainly change A to A{}, but it's a breaking change, and many other places need fixes.