【发布时间】:2017-04-18 12:54:57
【问题描述】:
我正在使用 OpenWeatherMap API 检索 16 天的预报信息。
http://www.json-generator.com/api/json/get/cuDhZDicMO?indent=2
从这样的 JSON 中,我能够检索到 cod 的值。这意味着 API 一切正常。我在调试时对其进行了测试,API 工作正常,因为我能够检索cod 的值。
但是我在ForecastInfo 数据模型中的列表有问题。你能看看那个并告诉我我哪里出错了吗?因为它没有检索该列表下的数据。我附上了我的forecastInfo,它是 JSON 的数据模型。非常感谢!
import java.util.ArrayList;
import java.util.List;
public class ForecastInfo {
public final double cod;
public List<LIST> list = new ArrayList<LIST>();
public List<LIST> getList() {
return list;
}
public ForecastInfo(List<LIST> list,double cod)
{
this.cod=cod;
this.list=list;
}
class LIST {
public final long dt;
public final Temp temp;
public LIST(long dt,Temp temp) {
this.dt = dt;
this.temp=temp;
}
class Temp
{
public final double day;
public Temp(double day){
this.day=day;
}
}
}
}
【问题讨论】:
-
您的映射应该可以工作。您面临的确切问题是什么?