File: json.rs

package info (click to toggle)
rust-minreq 2.13.4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 368 kB
  • sloc: makefile: 2
file content (13 lines) | stat: -rw-r--r-- 413 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
//! This example demonstrates the `json-using-serde` feature.

fn main() -> Result<(), minreq::Error> {
    let response = minreq::get("http://httpbin.org/anything")
        .with_body("Hello, world!")
        .send()?;

    // httpbin.org/anything returns the body in the json field "data":
    let json: serde_json::Value = response.json()?;
    println!("\"Hello, world!\" == {}", json["data"]);

    Ok(())
}