吉安感知网项目-后端
xiebin
2026-01-06 d207a86cdf1ab52ef8cb7cd83bad8fceab8038cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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<WeatherInfo> javaList = forecast.toJavaList(WeatherInfo.class);
        return javaList.get(0);
 
    }
 
 
}