大佬们,这个为啥会报错呀
大佬们,这个为啥会报错呀
大佬们,这个为啥会报错呀
2022-01-20
我执行3天的方法会报错,可能因为接口返回数据有变化。我自己重新修改了一下w3d 的方法,仿照w24h方法。才获得数据。具体修改如下,仅供参考:
List<DayWeather> (String appCodeString area) { List<DayWeather> resultList = ArrayList<DayWeather>(){ OkHttpClient client = OkHttpClient()Request request = Request.Builder() .get() .url(+ area) .header(+ appCode) .build()Call call = client.newCall(request)Response response = call.execute()Gson gson = GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.) .create()String resBody = response.body().string()Map result = gson.fromJson(resBodyTypeToken<Map>() { }.getType())List<Map<StringString>> dayList = .getValue(resultArrayList.)(dayList == || dayList.size() == ){ ArrayList<DayWeather>()} (Map<StringString> day : dayList) { (i=i <=i++){ DayWeather dayWeather = DayWeather()dayWeather.setYear(day.get().substring())dayWeather.setMonth(day.get().substring())dayWeather.setDay(day.get().substring())dayWeather.setDayAirTemperature(day.get())dayWeather.setNightAirTemperature(day.get())dayWeather.setDayWeather(day.get())dayWeather.setNightWeather(day.get())dayWeather.setDayWindPower(day.get())dayWeather.setNightWindPower(day.get())resultList.add(dayWeather)} } } (Exception e) { RuntimeException(e)} resultList}
举报