Skip to main content

hello_world/
hello_world.rs

1//! Minimal example: parse JSON and stringify it back with preserved formatting.
2
3use c12_parser::{parse_json, stringify_json};
4use serde_json::Value;
5
6fn main() {
7    let text = r#"
8{
9  "name": "c12-parser",
10  "version": "1.0.0"
11}
12"#;
13
14    let formatted = parse_json::<Value>(text, None).expect("parse");
15    println!(
16        "Parsed value: {} {}",
17        formatted.value["name"], formatted.value["version"]
18    );
19
20    let out = stringify_json(&formatted, None).expect("stringify");
21    println!("Roundtrip output:\n{}", out);
22}