2016-05-02 8 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を解析する方法](0120-18753)をご覧ください。 –

+0

あなたのコードは今ではアンドロイドスタジオですすべてのクラスとメソッドは廃止されました... –

+0

Yah私は彼らが廃止予定ですが、Json Stringからデータを取得する方法は同じです。サーバーからJSONを読み込む方法が変更されました。 –

答えて

1

あなたは@Shree Krishnaのコメントを気にする必要があります。あなたは

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

はあなたがJSONデータの読み方に係るシュリークリシュナのリンクを訪問しなければならない –

+0

....そんなに先生、それは作業のuに感謝します。 – Bharatesh

+0

はい、しかし私はloopjを使ってjsonデータを読み込みます... –

関連する問題