fn extract_string_value_from_json(
    json_object: &Value,
    key: &str,
) -> Result<String, CredentialsError> {
    match json_object.get(key) {
        Some(v) => Ok(v.as_str()
            .expect(&format!("{} value was not a string", key))
            .to_owned()),
        None => Err(CredentialsError::new(format!(
            "Couldn't find {} in response.",
            key
        ))),
    }
}
/// Reduces Boilerplate on getting json values. Wraps `serde_json::Value.get(key)`.
Reduces Boilerplate on getting json values.
Reduces Boilerplate on getting json values .
fn extract_string_value_from_json(
    json_object: &Value,
    key: &str,
) -> Result<String, CredentialsError> {
    match json_object.get(key) {
        Some(v) => Ok(v.as_str()
            .expect(&format!("{} value was not a string", key))
            .to_owned()),
        None => Err(CredentialsError::new(format!(
            "Couldn't find {} in response.",
            key
        ))),
    }
}
fn extract_string_value_from_json ( json_object : & Value , key : & str , ) -> Result < String , CredentialsError > { match json_object . get ( key ) { Some ( v ) => Ok ( v . as_str ( ) . expect ( & format ! ( " " key ) ) . to_owned ( ) ) , None => Err ( CredentialsError :: new ( format ! ( " " key ) ) ) , } }
Reduces Boilerplate on getting json values.
Reduces Boilerplate on getting json values .
json_object
&Value
key
&str
json_object
&Value
key
&str