Is it possible to take the last / penultimate element of a JSON Array file hosted on GitHub, without downloading the entire file?
Because the file is 10 MB, I only need the last two cells of the array, in fact every time I go to get the information it takes a lot of time to load due to the weight of the file.
File link: https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-json/dpc-covid19-ita-regioni.json
I retrive the information with this code:
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, JSON_OLD, null, response -> {
try{
for(int i = response.length() - 42; i < response.length() - 21; i++){
JSONObject jsonObject = response.getJSONObject(i);
oldRegionData.add(new RegionData(Integer.parseInt(jsonObject.getString("dimessi_guariti")),Integer.parseInt(jsonObject.getString("deceduti")), jsonObject.getString("denominazione_regione"), Integer.parseInt(jsonObject.getString("nuovi_positivi"))));
}
getNewData(queue);
} catch (JSONException e) {
e.printStackTrace();
}
}, error -> Log.println(Log.ERROR,"Error", "Error while performing this action"));
queue.add(jsonArrayRequest);