api与密度转换公式_单位换算API接口_免费数据接口 - 极速数据

package api.jisuapi.unitconvert;

import api.util.HttpUtil;

import net.sf.json.JSONObject;

public class Unit {

public static final String APPKEY = "your_appkey_here";// 你的appkey

public static final String URL = "https://api.jisuapi.com/unitconvert/unit";

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");

if (resultarr.opt("length") != null) {

JSONObject list = resultarr.optJSONObject("length");

if (list.opt("光年") != null) {

JSONObject guang = list.optJSONObject("光年");

String ename1 = guang.getString("ename");

String symbol = guang.getString("symbol");

String ratio = guang.getString("ratio");

System.out.println(ename1 + " " + symbol + " " + ratio);

}

if (list.opt("天文单位") != null) {

JSONObject tian = list.optJSONObject("天文单位");

String ename1 = tian.getString("ename");

String symbol = tian.getString("symbol");

String ratio = tian.getString("ratio");

System.out.println(ename1 + " " + symbol + " " + ratio);

}

if (list.opt("千米") != null) {

JSONObject qian = list.optJSONObject("千米");

String ename1 = qian.getString("ename");

String symbol = qian.getString("symbol");

String ratio = qian.getString("ratio");

String alias = qian.getString("alias");

System.out.println(ename1 + " " + symbol + " " + ratio + " " + alias);

}

if (list.opt("米") != null) {

JSONObject mi = list.optJSONObject("米");

String ename1 = mi.getString("ename");

String symbol = mi.getString("symbol");

String ratio = mi.getString("ratio");

String isSI = mi.getString("isSI");

System.out.println(ename1 + " " + symbol + " " + ratio + " " + isSI);

}

}

if (resultarr.opt("area") != null) {

JSONObject area = resultarr.optJSONObject("area");

if (area.opt("平方千米") != null) {

JSONObject ping = area.optJSONObject("平方千米");

String ename1 = ping.getString("ename");

String symbol = ping.getString("symbol");

String ratio = ping.getString("ratio");

System.out.println(ename1 + " " + symbol + " " + ratio);

}

if (area.opt("公顷") != null) {

JSONObject gong = area.optJSONObject("公顷");

String ename1 = gong.getString("ename");

String symbol = gong.getString("symbol");

String ratio = gong.getString("ratio");

System.out.println(ename1 + " " + symbol + " " + ratio);

}

if (area.opt("平方米") != null) {

JSONObject ping = area.optJSONObject("平方米");

String ename1 = ping.getString("ename");

String symbol = ping.getString("symbol");

String ratio = ping.getString("ratio");

String isSI = ping.getString("isSI");

System.out.println(ename1 + " " + symbol + " " + ratio + " " + isSI);

}

if (area.opt("公亩") != null) {

JSONObject mu = area.optJSONObject("公亩");

String ename1 = mu.getString("ename");

String symbol = mu.getString("symbol");

String ratio = mu.getString("ratio");

System.out.println(ename1 + " " + symbol + " " + ratio);

}

}

}

} catch (Exception e) {

e.printStackTrace();

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值