注册和风天气获取key,请求数据时需要用到,具体可查看 官方文档

请求数据示例

3-10天天气预报

{
    "HeWeather6": [
        {
            "basic": {
                "cid": "CN101010100",
                "location": "北京",
                "parent_city": "北京",
                "admin_area": "北京",
                "cnty": "中国",
                "lat": "39.90498734",
                "lon": "116.40528870",
                "tz": "8.0"
            },
            "daily_forecast": [
                {
                    "cond_code_d": "103",
                    "cond_code_n": "101",
                    "cond_txt_d": "晴间多云",
                    "cond_txt_n": "多云",
                    "date": "2017-10-26",
                    "hum": "57",
                    "pcpn": "0.0",
                    "pop": "0",
                    "pres": "1020",
                    "tmp_max": "16",
                    "tmp_min": "8",
                    "uv_index": "3",
                    "vis": "16",
                    "wind_deg": "0",
                    "wind_dir": "无持续风向",
                    "wind_sc": "微风",
                    "wind_spd": "5"
                },
                {
                    "cond_code_d": "101",
                    "cond_code_n": "501",
                    "cond_txt_d": "多云",
                    "cond_txt_n": "雾",
                    "date": "2017-10-27",
                    "hum": "56",
                    "pcpn": "0.0",
                    "pop": "0",
                    "pres": "1018",
                    "tmp_max": "18",
                    "tmp_min": "9",
                    "uv_index": "3",
                    "vis": "20",
                    "wind_deg": "187",
                    "wind_dir": "南风",
                    "wind_sc": "微风",
                    "wind_spd": "6"
                },
                {
                    "cond_code_d": "101",
                    "cond_code_n": "101",
                    "cond_txt_d": "多云",
                    "cond_txt_n": "多云",
                    "date": "2017-10-28",
                    "hum": "26",
                    "pcpn": "0.0",
                    "pop": "0",
                    "pres": "1029",
                    "tmp_max": "17",
                    "tmp_min": "5",
                    "uv_index": "2",
                    "vis": "20",
                    "wind_deg": "2",
                    "wind_dir": "北风",
                    "wind_sc": "3-4",
                    "wind_spd": "19"
                }
            ],
            "status": "ok",
            "update": {
                "loc": "2017-10-26 23:09",
                "utc": "2017-10-26 15:09"
            }
        }
    ]
}

返回的数据为data,object表示对象,array表示数组:

data object
HeWeather6 array
HeWeather6数组第一项 object
basic object
daily_forecast array
daily_forecast数组中 object

解码示例:


String data=数据
JSONObject jo=new JSONObject(data);
JSONArray ja=jo.getJSONArray("HeWeather6");
JSONObject joo=ja.getJSONObject(0);
JSONArray daily=joo.getJSONArray("daily_forecast");
for(int i=0;i<daily.length();i++)
{
     JSONObject day=daily.getJSONObject(i);
     String date=day.getString("date");
     String weather=day.getString("cond_txt_d");
     //获取其他数据

等待也是约会的一部分嘛