Skip to main content

json/
json.rs

1//! This example demonstrates the `json-using-serde` feature.
2
3fn main() -> Result<(), minreq::Error> {
4    let response = minreq::get("http://httpbin.org/anything")
5        .with_body("Hello, world!")
6        .send()?;
7
8    // httpbin.org/anything returns the body in the json field "data":
9    let json: serde_json::Value = response.json()?;
10    println!("\"Hello, world!\" == {}", json["data"]);
11
12    Ok(())
13}