2016-05-02 227 views
-3
results: { //this is json api 

Match: [ 
    { 
    group: "", 
    matchid: "193894", 
    mtype: "t20", 
    series_id: "12437", 
    series_name: "Indian Premier League, 2016", 
    stage: "heat", 
    status: "pre", 
    MatchNo: "Match 30", 
    Venue: { 
    venueid: "90", 
    content: "M.Chinnaswamy Stadium, Bengaluru" 
    }, 
    StartDate: "2016-05-02T20:00:00+05:30", 
    EndDate: "2016-05-03T00:00:00+05:30", 
    MatchTimeSpan: "Day-Night", 
    Team: [ 
    { 
    Team: "Bangalore", 
    role: "", 
    teamid: "1105" 
    }, 
    { 
    Team: "Kolkata", 
    role: "", 
    teamid: "1106" 
    } 
    ], 
    date_match_start: "20160502143000", 
    date_match_end: "20160502183000" 
    } 

如何獲得團隊名稱,如班加羅爾與加爾各答。如何獲得團隊名稱,如團隊A與團隊b

+3

可能重複的[如何在Android中解析JSON](http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android) –

+0

您的代碼是如此之舊現在android studio棄用所有的類和方法... –

+0

是的,我知道他們已被棄用,但從Json字符串獲取數據的方式是相同的。從服務器讀取JSON的方式已更改。 –

回答

1

你必須介意@Shree克里希納的評論。您可以閱讀像下面

try { 
     JSONObject object = new JSONObject(your_response);//your json result 
     JSONArray array = object.getJSONArray("Match"); 
     JSONObject firstMatch = array.getJSONObject(0);//first position of array 

     JSONArray teams = firstMatch.getJSONArray("Team");//read teams details 
     JSONObject firstTeam = teams.getJSONObject(0);//get first team 
     String team1Name = firstTeam.getString("Team"); 
     JSONObject secondTeam = teams.getJSONObject(1);//get second team 
     String team2Name = secondTeam.getString("Team"); 
    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 

happyCoding您的JSON數據;

+0

非常感謝你,先生它的工作.... –

+0

你必須訪問Shree Krishna關於如何閱讀json數據的鏈接。 – Bharatesh

+0

是的,但即時通訊使用loopj讀取json數據... –