I have a Problem to access json data in a 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 for the getJSONArray("matchdata");
But I can not access matchdata->match_results->match_result[0]->result_name
or
matchdata->goals->goal[0]->goal_getter_name
Here is my 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 I access eg. matchdata->match_results->match_result[0]->result_name
Here the 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"
| | | | | )
| | | | )
| | | )