我已經從我的氣象數據進行解析我是能夠成功地提取描述,最小和最大溫度,但日期是未知格式如何處理的日期將其轉換成可讀格式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'表示,您可以將解決方案集成到您的代碼中 –