-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"
    }

How to get both team name like Bangalore versus Kolkata.

0xDEADC0DE
  • 2,453
  • 1
  • 17
  • 22
  • 3
    Possible duplicate of [How to parse JSON in Android](http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android) – Shree Krishna May 02 '16 at 11:14
  • sir your code is so old now android studio deprecated all class and method... – Sandeep Kumar May 03 '16 at 05:07
  • Yah I know they are deprecated, But the way of getting data from Json String is same. The way of reading JSON from server has been changed. – Shree Krishna May 03 '16 at 05:14
  • yah thank u for helping me.. – Sandeep Kumar May 03 '16 at 05:26
  • hello sir r u there...i have a question...it have second object of match there is a one team in a object first is Team array and second is Team object bcoz there is only one team how to read json dada.. – Sandeep Kumar May 06 '16 at 08:04
  • Team: [ { Team: "Bangalore", role: "", teamid: "1105" }, { Team: "Kolkata", role: "", teamid: "1106" } ], // in second object .... Team: { Team: "Bangalore", role: "", teamid: "1105" }, – Sandeep Kumar May 06 '16 at 08:05

1 Answers1

1

You must mind @Shree Krishna's comment. You can read your json data like below

    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();
    }
Bharatesh
  • 8,943
  • 3
  • 38
  • 67
  • you must visit Shree Krishna's link regarding to how to read json data. – Bharatesh May 02 '16 at 11:54
  • hello sir r u there...i have a question...it have second object of match there is a one team in a object first is Team array and second is Team object bcoz there is only one team how to read json dada.. – Sandeep Kumar May 06 '16 at 08:02
  • Team: [ { Team: "Bangalore", role: "", teamid: "1105" }, { Team: "Kolkata", role: "", teamid: "1106" } ], // in second object .... Team: { Team: "Bangalore", role: "", teamid: "1105" }, – Sandeep Kumar May 06 '16 at 08:07