c12-parser 1.1.0

Toolbox for parsing and stringifying various formats, including JSON, JSON5, JSONC, INI, TOML, and YAML.
Documentation
//! Example: parse JSON with format preservation and optional custom indent.

use c12_parser::{FormatOptions, parse_json, stringify_json};
use serde_json::Value;

fn main() {
    let text = r#"  { "a": 1, "b": [2, 3] }  "#;

    let formatted = parse_json::<Value>(text, None).expect("parse");
    println!("Parsed: {:?}", formatted.value);

    let out = stringify_json(&formatted, None).expect("stringify");
    println!("Stringify (preserves outer whitespace): {:?}", out);

    let mut opts = FormatOptions::default();
    opts.indent = Some(4);
    let out_indent = stringify_json(&formatted, Some(opts)).expect("stringify");
    println!("Stringify (indent=4):\n{}", out_indent);
}