const char*tom_date [3];
const char*tom_weather [3];
String tom_code [3];
const char*tom_high [3];
const char*tom_low [3];
const char*tom_rainfall [3];
const char*tom_humidity[3];
const char*wind_speed[3];
//定义指针数组
StaticJsonDocument<1024> doc;
for(int i=0;i<3;i++){
JsonObject results_0_daily_tom = results_0["daily"][i];
tom_date [i] = results_0_daily_tom["date"]; // "2021-11-24"日期
tom_weather [i] = results_0_daily_tom["text_day"]; // "多云", "晴", "晴"
const char* results_0_daily_code = results_0_daily_tom["code_day"]; // "4", "0", "0"
tom_code [i] =results_0_daily_code;
tom_rainfall [i] = results_0_daily_tom["precip"]; // "0.00"降雨概率
tom_high [i] = results_0_daily_tom["high"]; // "20"最高温度
tom_low [i] = results_0_daily_tom["low"]; // "13"最低温度
tom_humidity[i] = results_0_daily_tom["humidity"]; // "53"
wind_speed[i] = results_0_daily_tom["wind_speed"]; // "23.4"
// results_0_daily_wind_direction = results_0_daily["wind_direction"]; // "北" 风向
// results_0_daily_rainfall = results_0_daily["rainfall"]; // "0.00" 降水量
}
返回的结果只有两天的结果而第三天的结果没有,但我请求的json文件是请求的今天明天和后天的结果,json也能正确获取到返回信息,当我解析json时数组却只有两天的内容
将后天的结果获取回来