https://cdn.sportmonks.com/soccer/json/champions-league-20172018-standings.json
im intending to take data from this JSON, only the name (group A,B,etc) for the first activity. i have learn how to extract data from https://www.thecrazyprogrammer.com/example_data/fruits_array.json before but how do i modify my codes so that i can extract specific data rather than all the data like in the fruits JSON example.
this is the code for the fruit array
public class Matches extends AppCompatActivity {
ListView fruitsList;
String url = "https://www.thecrazyprogrammer.com/example_data/fruits_array.json";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_matches);
fruitsList = (ListView)findViewById(R.id.fruitsList);
StringRequest request = new StringRequest(url, new Response.Listener<String>() {
@Override
public void onResponse(String string) {
parseJsonData(string);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(getApplicationContext(), "Some error occurred!!", Toast.LENGTH_SHORT).show();
}
});
RequestQueue rQueue = Volley.newRequestQueue(Matches.this);
rQueue.add(request);
}
void parseJsonData(String jsonString) {
try {
JSONObject object = new JSONObject(jsonString);
JSONArray fruitsArray = object.getJSONArray("fruits");
ArrayList al = new ArrayList();
for(int i = 0; i < fruitsArray.length(); ++i) {
al.add(fruitsArray.getString(i));
}
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, al);
fruitsList.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
}