首页 车型大全 车型大全示例代码 根据ID获取车型详情[Java]

根据ID获取车型详情示例代码[Java]

作者:xiezhongpian 阅读数:1491 上传时间:2017-05-09

根据ID获取车型详情

package api.jisuapi.car;

import api.util.HttpUtil;
import net.sf.json.JSONObject;

public class Detail {

	public static final String APPKEY = "your_appkey_here";// 你的appkey
	public static final String URL = "https://api.jisuapi.com/car/detail";
	public static final int carid = 2571;// 车ID

	public static void Get() {
		String result = null;
		String url = URL + "?appkey=" + APPKEY + "&carid=" + carid;

		try {
			result = HttpUtil.sendGet(url, "utf-8");
			JSONObject json = JSONObject.fromObject(carid);
			if (json.getInt("status") != 0) {
				System.out.println(json.getString("msg"));
			} else {
				JSONObject resultarr = json.optJSONObject("result");
				String id = resultarr.getString("id");
				String name = resultarr.getString("name");
				String initial = resultarr.getString("initial");
				String parentid = resultarr.getString("parentid");
				String logo = resultarr.getString("logo");
				String price = resultarr.getString("price");
				String yeartype = resultarr.getString("yeartype");
				String productionstate = resultarr.getString("productionstate");
				String salestate = resultarr.getString("salestate");
				String sizetype = resultarr.getString("sizetype");
				String depth = resultarr.getString("depth");
				System.out.println(id + " " + name + " " + initial + " " + parentid + " " + logo + " " + price + " "
						+ yeartype + " " + productionstate + " " + salestate + " " + sizetype + " " + depth);
				if (resultarr.opt("basic") != null) {
					JSONObject basic = resultarr.optJSONObject("basic");
					String price1 = basic.getString("price");
					String saleprice = basic.getString("saleprice");
					String warrantypolicy = basic.getString("warrantypolicy");
					String vechiletax = basic.getString("vechiletax");
					String displacement = basic.getString("displacement");
					String gearbox = basic.getString("gearbox");
					String comfuelconsumption = basic.getString("comfuelconsumption");
					String userfuelconsumption = basic.getString("userfuelconsumption");
					String officialaccelerationtime100 = basic.getString("officialaccelerationtime100");
					String testaccelerationtime100 = basic.getString("testaccelerationtime100");
					String maxspeed = basic.getString("maxspeed");
					String seatnum = basic.getString("seatnum");
					System.out.println("基本信息:" + price1 + " " + saleprice + " " + warrantypolicy + " " + vechiletax
							+ " " + displacement + " " + gearbox + " " + comfuelconsumption + " " + userfuelconsumption
							+ " " + officialaccelerationtime100 + " " + testaccelerationtime100 + " " + maxspeed + " "
							+ seatnum);
				}
				if (resultarr.opt("body") != null) {
					JSONObject body = resultarr.optJSONObject("body");
					String color = body.getString("color");
					String len = body.getString("len");
					String width = body.getString("width");
					String height = body.getString("height");
					String wheelbase = body.getString("wheelbase");
					String fronttrack = body.getString("fronttrack");
					String reartrack = body.getString("reartrack");
					String weight = body.getString("weight");
					String fullweight = body.getString("fullweight");
					String mingroundclearance = body.getString("mingroundclearance");
					String approachangle = body.getString("approachangle");
					String departureangle = body.getString("departureangle");
					String luggagevolume = body.getString("luggagevolume");
					String luggagemode = body.getString("luggagemode");
					String luggageopenmode = body.getString("luggageopenmode");
					String inductionluggage = body.getString("inductionluggage");
					String doornum = body.getString("doornum");
					String tooftype = body.getString("tooftype");
					String hoodtype = body.getString("hoodtype");
					String roofluggagerack = body.getString("roofluggagerack");
					String sportpackage = body.getString("sportpackage");
					System.out.println("车体:" + color + " " + len + " " + width + " " + height + " " + wheelbase + " "
							+ fronttrack + " " + reartrack + " " + weight + " " + fullweight + " " + mingroundclearance
							+ " " + approachangle + " " + departureangle + " " + luggagevolume + " " + luggagemode + " "
							+ luggageopenmode + " " + inductionluggage + " " + doornum + " " + tooftype + " " + hoodtype
							+ " " + roofluggagerack + " " + sportpackage);
				}
				if (resultarr.opt("engine") != null) {
					JSONObject engine = resultarr.optJSONObject("engine");
					String position = engine.getString("position");
					String model = engine.getString("model");
					String displacement = engine.getString("displacement");
					String displacementml = engine.getString("displacementml");
					String intakeform = engine.getString("intakeform");
					String cylinderarrangetype = engine.getString("cylinderarrangetype");
					String cylindernum = engine.getString("cylindernum");
					String valvetrain = engine.getString("valvetrain");
					String valvestructure = engine.getString("valvestructure");
					String compressionratio = engine.getString("compressionratio");
					String bore = engine.getString("bore");
					String stroke = engine.getString("stroke");
					String maxhorsepower = engine.getString("maxhorsepower");
					String maxpower = engine.getString("maxpower");
					String maxpowerspeed = engine.getString("maxpowerspeed");
					String maxtorque = engine.getString("maxtorque");
					String maxtorquespeed = engine.getString("maxtorquespeed");
					String fueltype = engine.getString("fueltype");
					String fuelgrade = engine.getString("fuelgrade");
					String fuelmethod = engine.getString("fuelmethod");
					String fueltankcapacity = engine.getString("fueltankcapacity");
					String cylinderheadmaterial = engine.getString("cylinderheadmaterial");
					String cylinderbodymaterial = engine.getString("cylinderbodymaterial");
					String environmentalstandards = engine.getString("environmentalstandards");
					String startstopsystem = engine.getString("startstopsystem");
					System.out.println("发动机:" + position + " " + model + " " + displacement + " " + displacementml + " "
							+ intakeform + " " + cylinderarrangetype + " " + cylindernum + " " + valvetrain + " "
							+ valvestructure + " " + compressionratio + " " + bore + " " + stroke + " " + maxhorsepower
							+ " " + maxpower + " " + maxpowerspeed + " " + maxtorque + " " + maxtorquespeed + " "
							+ fueltype + " " + fuelgrade + " " + fuelmethod + " " + fueltankcapacity + " "
							+ cylinderheadmaterial + " " + cylinderbodymaterial + " " + environmentalstandards + " "
							+ startstopsystem);
				}
				if (resultarr.opt("gearbox") != null) {
					JSONObject gearbox = resultarr.optJSONObject("gearbox");
					String gearbox1 = gearbox.getString("gearbox");
					String shiftpaddles = gearbox.getString("shiftpaddles");
					System.out.println("变速箱:" + gearbox1 + " " + shiftpaddles);
				}
				if (resultarr.opt("chassisbrake") != null) {
					JSONObject chassisbrake = resultarr.optJSONObject("chassisbrake");
					String bodystructure = chassisbrake.getString("bodystructure");
					String powersteering = chassisbrake.getString("powersteering");
					String frontbraketype = chassisbrake.getString("frontbraketype");
					String rearbraketype = chassisbrake.getString("rearbraketype");
					String parkingbraketype = chassisbrake.getString("parkingbraketype");
					String drivemode = chassisbrake.getString("drivemode");
					String airsuspension = chassisbrake.getString("airsuspension");
					String adjustablesuspension = chassisbrake.getString("adjustablesuspension");
					String frontsuspensiontype = chassisbrake.getString("frontsuspensiontype");
					String rearsuspensiontype = chassisbrake.getString("rearsuspensiontype");
					String centerdifferentiallock = chassisbrake.getString("centerdifferentiallock");
					System.out.println("底盘制动:" + bodystructure + " " + powersteering + " " + frontbraketype + " "
							+ rearbraketype + " " + parkingbraketype + " " + drivemode + " " + airsuspension + " "
							+ adjustablesuspension + " " + frontsuspensiontype + " " + rearsuspensiontype + " "
							+ centerdifferentiallock);
				}
				if (resultarr.opt("safe") != null) {
					JSONObject safe = resultarr.optJSONObject("safe");
					String airbagdrivingposition = safe.getString("airbagdrivingposition");
					String airbagfrontpassenger = safe.getString("airbagfrontpassenger");
					String airbagfrontside = safe.getString("airbagfrontside");
					String airbagfronthead = safe.getString("airbagfronthead");
					String airbagknee = safe.getString("airbagknee");
					String airbagrearside = safe.getString("airbagrearside");
					String airbagrearhead = safe.getString("airbagrearhead");
					String safetybeltprompt = safe.getString("safetybeltprompt");
					String safetybeltlimiting = safe.getString("safetybeltlimiting");
					String safetybeltpretightening = safe.getString("safetybeltpretightening");
					String frontsafetybeltadjustment = safe.getString("frontsafetybeltadjustment");
					String rearsafetybelt = safe.getString("rearsafetybelt");
					String tirepressuremonitoring = safe.getString("tirepressuremonitoring");
					String zeropressurecontinued = safe.getString("zeropressurecontinued");
					String centrallocking = safe.getString("centrallocking");
					String childlock = safe.getString("childlock");
					String remotekey = safe.getString("remotekey");
					String keylessentry = safe.getString("keylessentry");
					String keylessstart = safe.getString("keylessstart");
					String engineantitheft = safe.getString("engineantitheft");
					System.out.println("安全配置:" + airbagdrivingposition + " " + airbagfrontpassenger + " "
							+ airbagfrontside + " " + airbagfronthead + " " + airbagknee + " " + airbagrearside + " "
							+ airbagrearhead + " " + safetybeltprompt + " " + safetybeltlimiting + " "
							+ safetybeltpretightening + " " + frontsafetybeltadjustment + " " + rearsafetybelt + " "
							+ tirepressuremonitoring + " " + zeropressurecontinued + " " + centrallocking + " "
							+ childlock + " " + remotekey + " " + keylessentry + " " + keylessstart + " "
							+ engineantitheft);
				}
				if (resultarr.opt("wheel") != null) {
					JSONObject wheel = resultarr.optJSONObject("wheel");
					String fronttiresize = wheel.getString("fronttiresize");
					String reartiresize = wheel.getString("reartiresize");
					String sparetiretype = wheel.getString("sparetiretype");
					String hubmaterial = wheel.getString("hubmaterial");
					System.out.println(
							"车轮:" + fronttiresize + " " + reartiresize + " " + sparetiretype + " " + hubmaterial);
				}
				if (resultarr.opt("drivingauxiliary") != null) {
					JSONObject drivingauxiliary = resultarr.optJSONObject("drivingauxiliary");
					String abs = drivingauxiliary.getString("abs");
					String ebd = drivingauxiliary.getString("ebd");
					String brakeassist = drivingauxiliary.getString("brakeassist");
					String tractioncontrol = drivingauxiliary.getString("tractioncontrol");
					String esp = drivingauxiliary.getString("esp");
					String eps = drivingauxiliary.getString("eps");
					String automaticparking = drivingauxiliary.getString("automaticparking");
					String hillstartassist = drivingauxiliary.getString("hillstartassist");
					String hilldescent = drivingauxiliary.getString("hilldescent");
					String frontparkingradar = drivingauxiliary.getString("frontparkingradar");
					String reversingradar = drivingauxiliary.getString("reversingradar");
					String reverseimage = drivingauxiliary.getString("reverseimage");
					String panoramiccamera = drivingauxiliary.getString("panoramiccamera");
					String cruisecontrol = drivingauxiliary.getString("cruisecontrol");
					String adaptivecruise = drivingauxiliary.getString("adaptivecruise");
					String gps = drivingauxiliary.getString("gps");
					String automaticparkingintoplace = drivingauxiliary.getString("automaticparkingintoplace");
					String ldws = drivingauxiliary.getString("ldws");
					String activebraking = drivingauxiliary.getString("activebraking");
					String integralactivesteering = drivingauxiliary.getString("integralactivesteering");
					String nightvisionsystem = drivingauxiliary.getString("nightvisionsystem");
					String blindspotdetection = drivingauxiliary.getString("blindspotdetection");
					System.out.println("行车辅助:" + abs + " " + ebd + " " + brakeassist + " " + tractioncontrol + " " + esp
							+ " " + eps + " " + automaticparking + " " + hillstartassist + " " + hilldescent + " "
							+ frontparkingradar + " " + reversingradar + " " + reverseimage + " " + panoramiccamera
							+ " " + cruisecontrol + " " + adaptivecruise + " " + gps + " " + automaticparkingintoplace
							+ " " + ldws + " " + activebraking + " " + integralactivesteering + " " + nightvisionsystem
							+ " " + blindspotdetection);
				}
				if (resultarr.opt("doormirror") != null) {
					JSONObject doormirror = resultarr.optJSONObject("doormirror");
					String openstyle = doormirror.getString("openstyle");
					String electricwindow = doormirror.getString("electricwindow");
					String uvinterceptingglass = doormirror.getString("uvinterceptingglass");
					String privacyglass = doormirror.getString("privacyglass");
					String antipinchwindow = doormirror.getString("antipinchwindow");
					String skylightopeningmode = doormirror.getString("skylightopeningmode");
					String skylightstype = doormirror.getString("skylightstype");
					String rearwindowsunshade = doormirror.getString("rearwindowsunshade");
					String rearsidesunshade = doormirror.getString("rearsidesunshade");
					String rearwiper = doormirror.getString("rearwiper");
					String sensingwiper = doormirror.getString("sensingwiper");
					String electricpulldoor = doormirror.getString("electricpulldoor");
					String rearmirrorwithturnlamp = doormirror.getString("rearmirrorwithturnlamp");
					String externalmirrormemory = doormirror.getString("externalmirrormemory");
					String externalmirrorheating = doormirror.getString("externalmirrorheating");
					String externalmirrorfolding = doormirror.getString("externalmirrorfolding");
					String externalmirroradjustment = doormirror.getString("externalmirroradjustment");
					String rearviewmirrorantiglare = doormirror.getString("rearviewmirrorantiglare");
					String sunvisormirror = doormirror.getString("sunvisormirror");
					System.out.println("门窗后视镜:" + openstyle + " " + electricwindow + " " + uvinterceptingglass + " "
							+ privacyglass + " " + antipinchwindow + " " + skylightopeningmode + " " + skylightstype
							+ " " + rearwindowsunshade + " " + rearsidesunshade + " " + rearwiper + " " + sensingwiper
							+ " " + electricpulldoor + " " + rearmirrorwithturnlamp + " " + externalmirrormemory + " "
							+ externalmirrorheating + " " + externalmirrorfolding + " " + externalmirroradjustment + " "
							+ rearviewmirrorantiglare + " " + sunvisormirror);
				}
				if (resultarr.opt("light") != null) {
					JSONObject light = resultarr.optJSONObject("light");
					String light1 = light.getString("light");
					String headlighttype = light.getString("headlighttype");
					String optionalheadlighttype = light.getString("optionalheadlighttype");
					String headlightautomaticopen = light.getString("headlightautomaticopen");
					String headlightautomaticclean = light.getString("headlightautomaticclean");
					String headlightdelayoff = light.getString("headlightdelayoff");
					String headlightdynamicsteering = light.getString("headlightdynamicsteering");
					String headlightilluminationadjustment = light.getString("headlightilluminationadjustment");
					String headlightdimming = light.getString("headlightdimming");
					String frontfoglight = light.getString("frontfoglight");
					String readinglight = light.getString("readinglight");
					String interiorairlight = light.getString("interiorairlight");
					String daytimerunninglight = light.getString("daytimerunninglight");
					String ledtaillight = light.getString("ledtaillight");
					String lightsteeringassist = light.getString("lightsteeringassist");
					System.out.println("灯光:" + light1 + " " + headlighttype + " " + optionalheadlighttype + " "
							+ headlightautomaticopen + " " + headlightautomaticclean + " " + headlightdelayoff + " "
							+ headlightdynamicsteering + " " + headlightilluminationadjustment + " " + headlightdimming
							+ " " + frontfoglight + " " + readinglight + " " + interiorairlight + " "
							+ daytimerunninglight + " " + ledtaillight + " " + lightsteeringassist);
				}
				if (resultarr.opt("internalconfig") != null) {
					JSONObject internalconfig = resultarr.optJSONObject("internalconfig");
					String steeringwheelbeforeadjustment = internalconfig.getString("steeringwheelbeforeadjustment");
					String steeringwheelupadjustment = internalconfig.getString("steeringwheelupadjustment");
					String steeringwheeladjustmentmode = internalconfig.getString("steeringwheeladjustmentmode");
					String steeringwheelmemory = internalconfig.getString("steeringwheelmemory");
					String steeringwheelmaterial = internalconfig.getString("steeringwheelmaterial");
					String steeringwheelmultifunction = internalconfig.getString("steeringwheelmultifunction");
					String steeringwheelheating = internalconfig.getString("steeringwheelheating");
					String computerscreen = internalconfig.getString("computerscreen");
					String huddisplay = internalconfig.getString("huddisplay");
					String interiorcolor = internalconfig.getString("interiorcolor");
					String rearcupholder = internalconfig.getString("rearcupholder");
					String supplyvoltage = internalconfig.getString("supplyvoltage");
					System.out.println("内部配置:" + steeringwheelbeforeadjustment + " " + steeringwheelupadjustment + " "
							+ steeringwheeladjustmentmode + " " + steeringwheelmemory + " " + steeringwheelmaterial
							+ " " + steeringwheelmultifunction + " " + steeringwheelheating + " " + computerscreen + " "
							+ huddisplay + " " + interiorcolor + " " + rearcupholder + " " + supplyvoltage);

				}
				if (resultarr.opt("seat") != null) {
					JSONObject seat = resultarr.optJSONObject("seat");
					String sportseat = seat.getString("sportseat");
					String seatmaterial = seat.getString("seatmaterial");
					String seatheightadjustment = seat.getString("seatheightadjustment");
					String driverseatadjustmentmode = seat.getString("driverseatadjustmentmode");
					String auxiliaryseatadjustmentmode = seat.getString("auxiliaryseatadjustmentmode");
					String driverseatlumbarsupportadjustment = seat.getString("driverseatlumbarsupportadjustment");
					String driverseatshouldersupportadjustment = seat.getString("driverseatshouldersupportadjustment");
					String frontseatheadrestadjustment = seat.getString("frontseatheadrestadjustment");
					String rearseatadjustmentmode = seat.getString("rearseatadjustmentmode");
					String rearseatreclineproportion = seat.getString("rearseatreclineproportion");
					String rearseatangleadjustment = seat.getString("rearseatangleadjustment");
					String frontseatcenterarmrest = seat.getString("frontseatcenterarmrest");
					String rearseatcenterarmrest = seat.getString("rearseatcenterarmrest");
					String seatventilation = seat.getString("seatventilation");
					String seatheating = seat.getString("seatheating");
					String seatmassage = seat.getString("seatmassage");
					String electricseatmemory = seat.getString("electricseatmemory");
					String childseatfixdevice = seat.getString("childseatfixdevice");
					String thirdrowseat = seat.getString("thirdrowseat");
					System.out.println("座椅:" + sportseat + " " + seatmaterial + " " + seatheightadjustment + " "
							+ driverseatadjustmentmode + " " + auxiliaryseatadjustmentmode + " "
							+ driverseatlumbarsupportadjustment + " " + driverseatshouldersupportadjustment + " "
							+ frontseatheadrestadjustment + " " + rearseatadjustmentmode + " "
							+ rearseatreclineproportion + " " + rearseatangleadjustment + " " + frontseatcenterarmrest
							+ " " + rearseatcenterarmrest + " " + seatventilation + " " + seatheating + " "
							+ seatmassage + " " + electricseatmemory + " " + childseatfixdevice + " " + thirdrowseat);
				}
				if (resultarr.opt("entcom") != null) {
					JSONObject entcom = resultarr.optJSONObject("entcom");
					String locationservice = entcom.getString("locationservice");
					String bluetooth = entcom.getString("bluetooth");
					String externalaudiointerface = entcom.getString("externalaudiointerface");
					String builtinharddisk = entcom.getString("builtinharddisk");
					String cartv = entcom.getString("cartv");
					String speakernum = entcom.getString("speakernum");
					String audiobrand = entcom.getString("audiobrand");
					String dvd = entcom.getString("dvd");
					String cd = entcom.getString("cd");
					String consolelcdscreen = entcom.getString("consolelcdscreen");
					String rearlcdscreen = entcom.getString("rearlcdscreen");
					System.out.println("娱乐通讯:" + locationservice + " " + bluetooth + " " + externalaudiointerface + " "
							+ builtinharddisk + " " + cartv + " " + speakernum + " " + audiobrand + " " + dvd + " " + cd
							+ " " + consolelcdscreen + " " + rearlcdscreen);
				}
				if (resultarr.opt("aircondrefrigerator") != null) {
					JSONObject aircondrefrigerator = resultarr.optJSONObject("aircondrefrigerator");
					String airconditioningcontrolmode = aircondrefrigerator.getString("airconditioningcontrolmode");
					String tempzonecontrol = aircondrefrigerator.getString("tempzonecontrol");
					String rearairconditioning = aircondrefrigerator.getString("rearairconditioning");
					String reardischargeoutlet = aircondrefrigerator.getString("reardischargeoutlet");
					String airconditioning = aircondrefrigerator.getString("airconditioning");
					String airpurifyingdevice = aircondrefrigerator.getString("airpurifyingdevice");
					String carrefrigerator = aircondrefrigerator.getString("carrefrigerator");
					System.out.println("空调冰箱:" + airconditioningcontrolmode + " " + tempzonecontrol + " "
							+ rearairconditioning + " " + reardischargeoutlet + " " + airconditioning + " "
							+ airpurifyingdevice + " " + carrefrigerator);
				}
				if (resultarr.opt("actualtest") != null) {
					JSONObject actualtest = resultarr.optJSONObject("actualtest");
					String accelerationtime100 = actualtest.getString("accelerationtime100");
					String brakingdistance = actualtest.getString("brakingdistance");
					System.out.println("实际测试:" + accelerationtime100 + " " + brakingdistance);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}