我想从以下类型的json格式解析数据。任何人请帮助我。问题是没有关键从json object.eg获取价值:我怎样才能获得“America East Conference”的价值。任何人请帮助我,这对我来说非常重要
{
"America East Conference":{
"1":{
"Team_id":"156",
"Team_name":"UMBC Retrievers",
"Sport_code":"AE",
"Overall_wins":"4",
"Overall_losses":"26",
"Logo":"http:\/\/hoopla.sixsquaretechnologies.com\/logo_uploads\/UMBC Retrievers.png"
},
"2":{
"Team_id":"7",
"Team_name":"Albany Great Danes",
"Sport_code":"AE",
"Overall_wins":"24",
"Overall_losses":"8",
"Logo":"http:\/\/hoopla.sixsquaretechnologies.com\/logo_uploads\/Albany Great Danes.png"
}
},
"American Athletic Conference":{
"1":{
"Team_id":"61",
"Team_name":"Connecticut Huskies",
"Sport_code":"AE",
"Overall_wins":"20",
"Overall_losses":"13",
"Logo":"http:\/\/hoopla.sixsquaretechnologies.com\/logo_uploads\/Connecticut Huskies.png"
},
"2":{
"Team_id":"52",
"Team_name":"Cincinnati Bearcats",
"Sport_code":"AE",
"Overall_wins":"22",
"Overall_losses":"10",
"Logo":"http:\/\/hoopla.sixsquaretechnologies.com\/logo_uploads\/Cincinnati Bearcats.png"
}
}
}
答案 0 :(得分:1)
JSONObject main = new JSONObject(jsonString);
JSONObject East = main.getJSONObject("America East Conference");
JSONObject one = East.getJSONObject("1");
String Team_id = one.getString("Team_id");
String Team_name = one.getString("Team_name");
String Sport_code = one.getString("Sport_code");
String Overall_wins = one.getString("Overall_wins");
String Overall_losses = one.getString("Overall_losses");
JSONObject two = East.getJSONObject("2");
String Team_id2 = two.getString("Team_id");
String Team_name2 = two.getString("Team_name");
String Sport_code2 = two.getString("Sport_code");
String Overall_wins2 = two.getString("Overall_wins");
String Overall_losses2 = two.getString("Overall_losses");
JSONObject Athletic = main.getJSONObject("America Athletic Conference");
JSONObject one3 = Athletic.getJSONObject("1");
String Team_id3 = one.getString("Team_id");
String Team_name3 = one.getString("Team_name");
String Sport_code3 = one.getString("Sport_code");
String Overall_wins3 = one.getString("Overall_wins");
String Overall_losses3 = one.getString("Overall_losses");
JSONObject two4 = Athletic.getJSONObject("2");
String Team_id24 = two.getString("Team_id");
String Team_name24 = two.getString("Team_name");
String Sport_code24 = two.getString("Sport_code");
String Overall_wins24 = two.getString("Overall_wins");
String Overall_losses24 = two.getString("Overall_losses");