diff --git a/Cargo.toml b/Cargo.toml index ccd59dc..2eb29f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ once_cell = "1" url = "2" socks = { version = "0.3", optional = true } serde = { version = "1", optional = true } -serde_json = { version = ">=1,<1.0.94", optional = true } +serde_json = { version = ">=1.0.97", optional = true } encoding_rs = { version = "0.8", optional = true } cookie_store = { version = "0.19", optional = true, default-features = false, features = ["preserve_order"] } log = "0.4" diff --git a/src/response.rs b/src/response.rs index d8c15bc..2f56cc9 100644 --- a/src/response.rs +++ b/src/response.rs @@ -533,16 +533,13 @@ impl Response { #[cfg(feature = "json")] pub fn into_json(self) -> io::Result { use crate::stream::io_err_timeout; - use std::error::Error; let reader = self.into_reader(); serde_json::from_reader(reader).map_err(|e| { // This is to unify TimedOut io::Error in the API. - // We make a clone of the original error since serde_json::Error doesn't - // let us get the wrapped error instance back. - if let Some(ioe) = e.source().and_then(|s| s.downcast_ref::()) { - if ioe.kind() == io::ErrorKind::TimedOut { - return io_err_timeout(ioe.to_string()); + if let Some(kind) = e.io_error_kind() { + if kind == io::ErrorKind::TimedOut { + return io_err_timeout(e.to_string()); } }