More null handling in weather API responses
This commit is contained in:
parent
91b02c24fb
commit
e8ab11eff9
@ -33,9 +33,10 @@ impl UnibarModuleWeather {
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
deg_c = self.weather_info["features"][0]["properties"]["temperature"]["value"]
|
deg_c = self.weather_info["features"][0]["properties"]["temperature"]["value"]
|
||||||
.to_string().parse().unwrap();
|
.to_string().parse().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.opts.weather_units {
|
match self.opts.weather_units {
|
||||||
common::TemperatureUnits::Metric => return deg_c,
|
common::TemperatureUnits::Metric => return deg_c,
|
||||||
common::TemperatureUnits::Imperial => return (deg_c * 9.0 / 5.0) + 32.0,
|
common::TemperatureUnits::Imperial => return (deg_c * 9.0 / 5.0) + 32.0,
|
||||||
@ -203,6 +204,10 @@ impl bar_modules::BarModuleActions for UnibarModuleWeather {
|
|||||||
"".to_string()
|
"".to_string()
|
||||||
});
|
});
|
||||||
self.weather_info = serde_json::from_str(curl_reg_str.as_str()).unwrap();
|
self.weather_info = serde_json::from_str(curl_reg_str.as_str()).unwrap();
|
||||||
|
|
||||||
|
if self.weather_info["features"][0]["properties"]["temperature"]["value"] == serde_json::Value::Null {
|
||||||
|
self.weather_info = serde_json::Value::Null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user