Skip to main content

stringify_json5

Function stringify_json5 

Source
pub fn stringify_json5<T>(
    formatted: &Formatted<T>,
    _options: Option<FormatOptions>,
) -> Result<String, Error>
where T: Serialize,
Expand description

Stringifies a JSON5 value with preserved or configured formatting.

Examples found in repository?
examples/parse_json5.rs (line 22)
6fn main() {
7    let text = r#"
8{
9  name: 'c12-parser',
10  version: '1.0.0',
11  tags: [ 'config', 'parser', ],
12}
13"#;
14
15    let formatted = parse_json5::<Value>(text, None).expect("parse");
16    println!(
17        "Parsed: {} {}",
18        formatted.value["name"], formatted.value["version"]
19    );
20    println!("Tags: {:?}", formatted.value["tags"]);
21
22    let out = stringify_json5(&formatted, None).expect("stringify");
23    println!("Stringify:\n{}", out);
24}