Add response json example

ref https://github.com/seanmonstar/reqwest/pull/19#issuecomment-261789621
This commit is contained in:
Laurent Arnoud
2017-04-23 18:00:35 +02:00
parent af1f2f3a81
commit cc850a65cb
2 changed files with 16 additions and 0 deletions

15
examples/response_json.rs Normal file
View File

@@ -0,0 +1,15 @@
// cargo run --example response_json
extern crate reqwest;
#[macro_use]
extern crate serde_derive;
#[derive(Debug, Deserialize)]
struct Response {
origin: String,
}
fn main() {
let mut res = reqwest::get("https://httpbin.org/ip").unwrap();
println!("JSON: {:?}", res.json::<Response>());
}