I'd like to read a JSON file and print its contents. I'm trying to use the serde crate but can't understand why this does not work:
use serde_json;
use std::fs;
fn main() {
let path = "./src/input.json";
let data = fs::read_to_string(path).expect("Unable to read file");
let res = serde_json::from_str(&data);
println!("{}", res)
}
The error I get is:
the trait std::fmt::Display is not implemented
How can I read a JSON file? Is there a better way to do this? I could not find a complete example in either the serde docs or elsewhere.