c12-parser 1.1.0

Toolbox for parsing and stringifying various formats, including JSON, JSON5, JSONC, INI, TOML, and YAML.
Documentation
//! Example: parse INI into a nested map (formatting not preserved).

use c12_parser::{parse_ini, stringify_ini};

fn main() {
    let text = r#"
[server]
host = 127.0.0.1
port = 8080

[app]
name = my-app
"#;

    let map = parse_ini(text);
    println!("Sections: {:?}", map.keys().collect::<Vec<_>>());

    if let Some(server) = map.get("server") {
        println!(
            "server.host = {:?}",
            server.get("host").and_then(|v| v.as_deref())
        );
        println!(
            "server.port = {:?}",
            server.get("port").and_then(|v| v.as_deref())
        );
    }

    let out = stringify_ini(&map);
    println!("Stringify:\n{}", out);
}