json-rust
json-rust copied to clipboard
Allow parsing from `std::io::Read`
Currently, simply reading a file to a JsonValue
involves quite some boilerplate:
let mut contents = String::new();
let mut file = File::open(some_path)?;
file.read_to_string(&mut contents)?;
let json = json::parse(&contents)?;
This could be hugely improved by allowing parsing directly from a std::io::Read
:
let json = json::parse(File::open(some_path)?)?;
It may be useful to provide an load()
convenience wrapper specifically for such task as it may be in high demand.
alternative:
https://docs.rs/serde_json/latest/serde_json/fn.from_reader.html