package api.jisuapi.illegal; import api.util.HttpUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class Carorg { public static final String APPKEY = "your_appkey_here";// 你的appkey public static final String URL = "https://api.jisuapi.com/illegal/carorg"; public static void Get() { String result = null; String url = URL + "?appkey=" + APPKEY; try { result = HttpUtil.sendGet(url, "utf-8"); JSONObject json = JSONObject.fromObject(result); if (json.getInt("status") != 0) { System.out.println(json.getString("msg")); } else { JSONObject resultarr = json.optJSONObject("result"); JSONArray data = resultarr.optJSONArray("data"); for (int i = 0; i < data.size(); i++) { JSONObject obj = (JSONObject) data.opt(i); String province = obj.getString("province"); String lsprefix = obj.getString("lsprefix"); String lsnum = obj.getString("lsnum"); String carorg = obj.getString("carorg"); String frameno = obj.getString("frameno"); String engineno = obj.getString("engineno"); System.out.println( province + " " + lsprefix + " " + lsnum + " " + carorg + " " + frameno + " " + engineno); if (obj.opt("list") != null) { JSONArray list = obj.optJSONArray("list"); for (int j = 0; j < list.size(); j++) { JSONObject list_obj = (JSONObject) list.opt(j); String city = list_obj.getString("city"); String lsprefix1 = list_obj.getString("lsprefix"); String lsnum1 = list_obj.getString("lsnum"); String carorg1 = ""; if (list_obj.opt("carorg") != null) { carorg1 = list_obj.getString("carorg"); } String frameno1 = ""; if (list_obj.opt("frameno") != null) { frameno1 = list_obj.getString("frameno"); } String engineno1 = ""; if (list_obj.opt("engineno") != null) { engineno1 = list_obj.getString("engineno"); } System.out.println(city + " " + lsprefix1 + " " + lsnum1 + " " + carorg1 + " " + frameno1 + " " + engineno1); } } System.out.println(); } } } catch (Exception e) { e.printStackTrace(); } } }