我已经从我的气象数据进行解析我是能够成功地提取描述,最小和最大温度,但日期是未知格式如何处理的日期将其转换成可读格式JSON日期解析
"list":[
{
"dt":1497852000,
"temp":{
"day":301.14,
"min":294.81,
"max":301.14,
"night":294.81,
"eve":301.14,
"morn":301.14
},
"pressure":990.68,
"humidity":88,
"weather":[
{
"id":501,
"main":"Rain",
"description":"moderate rain",
"icon":"10d"
}
我的代码:
public static void JSONParsing(String forecastJsonStr) throws JSONException {
double MinTemp;
double MaxTemp;
String Date,description;
JSONObject forecastDate = new JSONObject(forecastJsonStr);
JSONArray ForecastData = forecastDate.getJSONArray("list");
for(int i =0 ; i< ForecastData.length();i++){
JSONObject weather = ForecastData.getJSONObject(i);
JSONObject Data = weather.getJSONObject("temp");
JSONObject Description = weather.getJSONArray("weather").getJSONObject(0);
description = Description.getString("description");
MinTemp = Data.getDouble("min");
MaxTemp = Data.getDouble("max");
}
}
格式是什么,它实际上在在JSON内? –
您的日期用'dt'表示,您可以将解决方案集成到您的代码中 –