日期:2014-05-18 浏览次数:20700 次
try{
myurl = new URL("https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?key=D0CCA1C6B04C07BBA05F04BE6D3E8E23&match_id="+matchId);
conn = myurl.openConnection();
httpURLConn = (HttpURLConnection)conn;
httpURLConn.setRequestMethod("GET");
reader = new BufferedReader(new InputStreamReader(httpURLConn.getInputStream(),"gbk"));
String lineStr = reader.readLine();
StringBuffer totalData = new StringBuffer();
while (lineStr!=null){
lineStr = reader.readLine();
totalData.append(lineStr);
}
String str = new String(totalData);
str = str.replaceAll("\t", "");
str = str.replaceAll("null", "");
str = "{"+str;
System.out.println(str);
JSONObject jsary=JSONObject.fromObject(str);//格式化成json对象
JSONObject.fromObject(str);
//JSONArray jsary=JSONArray.fromObject(str);
matchResult = jsary.getString("result");//这里读别的值都会报错
}catch (Exception e){
e.printStackTrace();
}