use serde::{Deserialize, Serialize};
use anyhow::Result;

fn main() -> Result<()> {
    #[derive(Serialize, Deserialize, Debug)]
    struct Data {
        boolean: bool,
        string: String,
        number: u8,
        #[serde(rename = "numbers")]
        array: [u8; 4],
    }

    let data = Data {
        boolean: false,
        string: String::from("data"),
        number: 42,
        array: [0,1,2,3],
    };

    println!("debug: {:?}", data);

    let json = serde_json::to_string(&data)?;

    println!("json: {json}");
    println!("json (pretty): \n{}", serde_json::to_string_pretty(&data)?);

    let data: Data = serde_json::from_str(&json)?;

    let toml = toml::to_string_pretty(&data)?;

    println!("toml (pretty):\n{toml}");

    Ok(())
}
