To deserialize a struct into a json file run a code similar to the following one :
let struct = Struct::create(); let slice_string_in_json_format = serde_json::to_string(&struct);
Instead to serielize a json file component into a struct you can use a similar pattern:
fn parsing_json_into_struct() -> Result<Struct> { // Open the json file let mut file_content = match File::open("file.json") { Ok( file) => file, Err(_) => panic!("Could not read the json file") }; // Transform content of the file into a string let mut contents = String::new(); match file_content.read_to_string(&mut contents) { Ok(_) => {}, Err(err) => panic!("Could not deserialize the file, error code: {}", err) }; let module: Result<Struct> = serde_json::from_str(&contents.as_str()); module }