/// Serializes the given object to a JSON file.
Serializes the given object to a JSON file.
Serializes the given object to a JSON file .
pub fn write_json_file<T: ?Sized>(json_path: &Path, value: &T) -> Result<()>
where
    T: Serialize,
{
    if let Some(parent) = json_path.parent() {
        fs::create_dir_all(parent)
            .with_context(|| format!("cannot create {}", parent.display()))?;
    }
    let file = File::create(json_path)
        .with_context(|| format!("cannot create {}", json_path.display()))?;
    serde_json::to_writer_pretty(&file, &value)
        .with_context(|| format!("cannot serialize {}", json_path.display()))
}
pub fn write_json_file < T : ? Sized > ( json_path : & Path , value : & T ) -> Result < ( ) > where T : Serialize , { if let Some ( parent ) = json_path . parent ( ) { fs :: create_dir_all ( parent ) . with_context ( | | format ! ( " " parent display ( ) ) ) ? ; } let file = File :: create ( json_path ) . with_context ( | | format ! ( " " json_path display ( ) ) ) ? ; serde_json :: to_writer_pretty ( & file , & value ) . with_context ( | | format ! ( " " json_path display ( ) ) ) }
Serializes the given object to a JSON file.
Serializes the given object to a JSON file .
json_path
&Path
value
&T