1 回答

TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊
首先,我建議您使用任何用于 android 的 http 庫(kù)(okHttp,volley ..)
但是如果你仍然想使用你實(shí)現(xiàn)它的方式,你需要在這里做一些改變:
while ((line = reader.readLine()) != null) {
buffer.append(line);
Log.d("Response: ", "> " + line); //here u ll get whole response...... :-)
}
String json = buffer.toString();
try {
String json = "";
JSONObject jsonObject = new JSONObject(json);
JSONObject league = jsonObject.getJSONObject("league");
JSONArray standard = league.getJSONArray("standard");
for (int i = 0;i<standard.length();i++){
JSONObject item = standard.getJSONObject(i);
String name = item.getString("firstName");
String lastName= item.getString("lastName");
}
} catch (JSONException e) {
e.printStackTrace();
}
添加回答
舉報(bào)