fn maybe_write_json<T: Serialize>(path: &str, obj: &T) -> Result<()>