package org.sxkj.common.utils; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.sxkj.common.model.WeatherInfo; import java.util.List; public class WeatherUtils { static String path = "http://t.weather.sojson.com/api/weather/city/"; static String path2 = "http://t.weather.itboy.net/api/weather/city/"; public static WeatherInfo getWeather(String cityCode) { String rspStr = HttpUtils.sendGet(path + cityCode, "utf-8"); JSONObject obj = JSONObject.parseObject(rspStr); JSONArray forecast = obj.getJSONObject("data").getJSONArray("forecast"); List javaList = forecast.toJavaList(WeatherInfo.class); return javaList.get(0); } }