I understand that what I'm fetching is already an array but still I'm not sure what to change here.
I have this which is returning data fine but I'm not sure what to do with the array to get the values into the map.
protected Void doInBackground(Void... params) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
// Retrieve JSON Objects from the given URL address
jsonobject = JSONfunctions
.getJSONfromURL("http://www.mywebsite.club/api/coffees");
try {
// Locate the array name in JSON
jsonarray = jsonobject.getJSONArray("coffees");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
map.put("title", jsonobject.getString("title"));
map.put("brand", jsonobject.getString("brand"));
map.put("price", jsonobject.getInt("price"));
map.put("brandlogo", jsonobject.getString("brandlogo"));
// Set the JSON Objects into the array
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}