日期:2014-05-16 浏览次数:20487 次
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { URL url = new URL("https://www.koobe.com.tw/AssociateAPIs/Data/Quota.aspx?bookid=20ddd93c-d34e-40ce-996f-4cf3dd322d16"); Reader reader = new InputStreamReader(new BufferedInputStream(url.openStream())); int c; String str = "["; while ((c = reader.read()) != -1) { str += (char)c; } str += "]"; reader.close(); System.out.println(str); //将字符串转百json数据 JSONArray ja = JSONArray.fromObject(str); JSONObject o=(JSONObject) ja.get(0); System.out.println(o.get("KoobeData"));?
?
[{"KoobeData":{"Quota":3}}]
{"Quota":3}