serde-rs / json

Strongly typed JSON library for Rust
Apache License 2.0
4.7k stars 536 forks source link

Serialize enum - only tag #1133

Open Cheban1996 opened 2 months ago

Cheban1996 commented 2 months ago

I want serialize only tag

#[derive(Serialize, Deserialize)]
#[serde(tag = "type")]
enum Message {
    Request { id: String, method: String, params: Params },
    Response { id: String, result: Value },
}
{"type": "Request"}

How make that and if impossible, maybe need implement onlytag?