android json multi dimensional array -


i have problem access json data in multi dimensional array. https://openligadb-json.heroku.com/api/matchdata_by_group_league_saison?group_order_id=20&league_saison=2010&league_shortcut=bl1

my code works fine getjsonarray("matchdata");

but can not access matchdata->match_results->match_result[0]->result_name

or

matchdata->goals->goal[0]->goal_getter_name

here code:

jsonobject json = null;            json = jsonfunctions.getjsonfromurl("http://openligadb-json.heroku.com/api/matchdata_by_group_league_saison?group_order_id="+ group_order_id +"&league_saison="+ league_saison +"&league_shortcut=" + league_shortcut);              if (json != null){        try{         jsonarray  openbuli = null;         openbuli = json.getjsonarray("matchdata");         mylist.clear();              for(int i=0;i<openbuli.length();i++){                                        hashmap<string, string> map = new hashmap<string, string>();                     jsonobject e = openbuli.getjsonobject(i);                    map.put("id",  string.valueof(i));                 map.put("group_name", e.getstring("group_name"));                 map.put("name_team1", e.getstring("name_team1"));                 map.put("name_team2", e.getstring("name_team2"));                 map.put("points_team1", e.getstring("points_team1"));                 map.put("points_team2", e.getstring("points_team2"));                 map.put("halbzeit", e.getstring("result_name"));                 map.put("first", e.getstring("name_team1") + " : " + e.getstring("name_team2") + "  " + points_team1 + " : " + points_team2);                 map.put("second", e.getstring("match_date_time"));                 mylist.add(map);             }              }        catch(jsonexception e){          log.e("log_tag", "error parsing data "+e.tostring());       }       } 

how can access eg. matchdata->match_results->match_result[0]->result_name

here json data:

$json ( |    matchdata => array (9) |    ( |    |    ['0'] ( |    |    |    league_name =  "1. fussball-bundesliga 2010/2011" |    |    |    match_is_finished =  true |    |    |    location ( |    |    |    |    location_id =  "0" |    |    |    ) |    |    |    match_date_time_utc =  "2011-01-28t19:30:00+00:00" |    |    |    id_team2 =  "55" |    |    |    league_saison =  "2010" |    |    |    match_results ( |    |    |    |    match_result => array (2) |    |    |    |    ( |    |    |    |    |    ['0'] ( |    |    |    |    |    |    result_name =  "endergebnis" |    |    |    |    |    |    result_order_id =  "1" |    |    |    |    |    |    result_type_name =  "nach 90 minuten" |    |    |    |    |    |    points_team1 =  "2" |    |    |    |    |    |    result_type_id =  "2" |    |    |    |    |    |    points_team2 =  "0" |    |    |    |    |    ) |    |    |    |    |    ['1'] ( |    |    |    |    |    |    result_name =  "halbzeit" |    |    |    |    |    |    result_order_id =  "2" |    |    |    |    |    |    result_type_name =  "halbzeit" |    |    |    |    |    |    points_team1 =  "2" |    |    |    |    |    |    result_type_id =  "1" |    |    |    |    |    |    points_team2 =  "0" |    |    |    |    |    ) |    |    |    |    ) |    |    |    ) |    |    |    group_id =  "294" |    |    |    icon_url_team1 =  "http://www.openligadb.de/images/teamicons/bayer_leverkusen.gif" |    |    |    league_shortcut =  "bl1" |    |    |    goals ( |    |    |    |    goal => array (2) |    |    |    |    ( |    |    |    |    |    ['0'] ( |    |    |    |    |    |    goal_id =  "4367" |    |    |    |    |    |    goal_getter_name =  "vidal" |    |    |    |    |    |    goal_mach_id =  "10171" |    |    |    |    |    |    goal_penalty =  false |    |    |    |    |    |    goal_score_team1 =  "1" |    |    |    |    |    |    goal_own_goal =  false |    |    |    |    |    |    goal_score_team2 =  "0" |    |    |    |    |    |    goal_overtime =  false |    |    |    |    |    |    goal_match_minute =  "21" |    |    |    |    |    |    goal_comment =  null |    |    |    |    |    |    goal_getter_id =  "1135" |    |    |    |    |    ) |    |    |    |    |    ['1'] ( |    |    |    |    |    |    goal_id =  "4368" |    |    |    |    |    |    goal_getter_name =  "rolfes" |    |    |    |    |    |    goal_mach_id =  "10171" |    |    |    |    |    |    goal_penalty =  false |    |    |    |    |    |    goal_score_team1 =  "2" |    |    |    |    |    |    goal_own_goal =  false |    |    |    |    |    |    goal_score_team2 =  "0" |    |    |    |    |    |    goal_overtime =  false |    |    |    |    |    |    goal_match_minute =  "42" |    |    |    |    |    |    goal_comment =  null |    |    |    |    |    |    goal_getter_id =  "511" |    |    |    |    |    ) |    |    |    |    ) |    |    |    ) 

i know should in comment rather answer unable comment due reputations putting in answer.

you can use gson library parse json response.

please provide json response easier understand.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -