serde-json enum

This commit is contained in:
Christoph J. Scherr 2024-06-24 13:35:35 +02:00
parent 8ddf0893ed
commit 32f9bc2ab7
1 changed files with 4 additions and 0 deletions

View File

@ -24,6 +24,7 @@ enum Color {
Green,
Yellow,
Red,
Custom(String)
}
use serde_repr::{Deserialize_repr, Serialize_repr};
@ -63,6 +64,9 @@ fn main() -> anyhow::Result<()> {
let color_str = serde_json::to_string(&color)?;
dbg!(&color_str);
let custom_color = Color::Custom("Morange".to_string());
dbg!(serde_json::to_string(&custom_color).unwrap());
let cl = CLike::Omaba;
let clrepr = serde_json::to_string(&cl)?;
dbg!(&clrepr);