Add response json example
ref https://github.com/seanmonstar/reqwest/pull/19#issuecomment-261789621
This commit is contained in:
@@ -21,3 +21,4 @@ libflate = "0.1.3"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.3"
|
||||
serde_derive = "0.9"
|
||||
|
||||
15
examples/response_json.rs
Normal file
15
examples/response_json.rs
Normal 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>());
|
||||
}
|
||||
Reference in New Issue
Block a user