Skip to main content

to_json

Function to_json 

Source
pub fn to_json(spec: &Har) -> Result<String, Error>
Expand description

Serialize a HAR to a JSON string.

Examples found in repository?
examples/printer.rs (line 11)
3fn main() {
4    let Some(path) = std::env::args_os().nth(1) else {
5        eprintln!("usage: cargo run --example printer -- <path-to.har>");
6        std::process::exit(2);
7    };
8
9    match from_path(&path) {
10        Ok(har) => {
11            let json = to_json(&har).expect("serializing parsed HAR as JSON should succeed");
12            println!("{json}");
13        }
14        Err(error) => {
15            eprintln!("{error}");
16            std::process::exit(1);
17        }
18    }
19}