From a5c6f2afbe16d0328750f83db66b93b89111313b Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 8 Aug 2018 10:27:42 +0800 Subject: Simplify response with json --- src/main.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 85d25e7..a5c10e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,10 +123,7 @@ fn on_submit(s: &mut Cursive, name: &str) { let mut link_vec: Vec = vec![]; let mut res = reqwest::get(&url).unwrap(); - let v: Value = match serde_json::from_str(&res.text().unwrap()) { - Ok(x) => x, - Err(x) => panic!("Failed to parse json\nReceived error {}", x), - }; + let v: Value = res.json().expect("Failed to parse json"); match get_extract(&v) { Ok(x) => extract = x, -- cgit v1.2.3