Files

31 lines
682 B
Rust

use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct ServiceConfig {
name: String,
enabled: bool,
retries: i64,
endpoints: Vec<String>,
}
fn main() -> wson::Result<()> {
let value = ServiceConfig {
name: "worker".to_string(),
enabled: true,
retries: 3,
endpoints: vec![
"https://a.example".to_string(),
"https://b.example".to_string(),
],
};
let text = wson::to_string(&value)?;
println!("text: {text}");
let decoded: ServiceConfig = wson::from_str(&text)?;
assert_eq!(decoded, value);
println!("round trip ok");
Ok(())
}