Hi, I am trying to extract some weather station data to put in a csv file, but I'm a bit lost in the desiarilizing stufff.
Here is the output of the API call
{
"code": 0,
"msg": "success",
"time": "1655152323",
"data": {
"rainfall": {
"rain_rate": {
"unit": "in\/hr",
"list": {
"1651377600": "0.00",
"1651377900": "0.00",
"1651378200": "0.00",
"1651378500": "0.00",
"1651378800": "0.00",
snip...
I want to get the data under "list".
Not sure if it's the best way to deal with this, but I tried to use a cascade of structs with Deserialize
#[derive(Debug, Serialize, Deserialize)]
struct StationData {
data: DataRainfall,
}
#[derive(Debug, Serialize, Deserialize)]
struct DataRainfall {
rainfall: Rainfall,
}
#[derive(Debug, Serialize, Deserialize)]
struct Rainfall {
rain_rate: String,
}
#[derive(Debug, Serialize, Deserialize)]
struct DailyRainRate {
unit: String,
list: Vec<Vec<String>>,
}
The data inside "List" would correspond to the struct DailyRainRate, but the compiler complains that it is receiving a Map instead of a String. Since it is not a named field, I am not sure how to deal with it.
Any help is appreciated