I’m trying to read data from JSON file in AndroidStudio with a format as follows:
{ "records": [ [1,"name1","1,9"], [2,"name2","0,74"], ... ]}
I want to have objects containing int, String, String (new Object for each row). Does someone know how to write that?
Advertisement
Answer
This may help
JSONObject jsonObject ;// your json body try { JSONArray jsonArray = jsonObject.getJSONArray("records"); for (int i = 0; i < jsonArray.length(); i++) { JSONArray jArray = jsonArray.getJSONArray(i);// for each row in records([2,"name2","0,74"]) } } catch (JSONException e) { e.printStackTrace(); }