-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Had to tweak the JSON examples a bit, but I think they're still readable and clear. Hopefully this fixes the MSRV tests!
- Loading branch information
Showing
5 changed files
with
17 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
/// This example demonstrates the `json-using-serde` feature. | ||
|
||
#[derive(serde::Deserialize)] | ||
struct Response { | ||
/// The field in which `http://httpbin.org/anything` returns the body. | ||
data: String, | ||
} | ||
|
||
fn main() -> Result<(), minreq::Error> { | ||
let response = minreq::get("http://httpbin.org/anything") | ||
.with_body("Hello, world!") | ||
.send()?; | ||
let json: Response = response.json()?; | ||
println!("Hello, world! == {}", &json.data); | ||
|
||
// httpbin.org/anything returns the body in the json field "data": | ||
let json: serde_json::Value = response.json()?; | ||
println!("\"Hello, world!\" == {}", json["data"]); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters