How to fetch this data using json.Is it an object or an array? I am confused. Below is my data and what I have implemented. I am unable to get any values. Please help me to fetch the values.
JSONObject jobject = new JSONObject(response);
JSONArray jsonArray = jobject.getJSONArray("variety");
for (int i =0; i<=jsonArray.length();i++){
jobject= jsonArray.getJSONObject(i);
txt_today_671.setText(jobject.getString("variety.coc671"));
}
{
"status": 200,
"variety": {
"coc671": {
"today": 0,
"todate": 0
},
"co92005": {
"today": 0,
"todate": 0
},
},
"others": {
"today": 0,
"todate": 0
}
},
"distance": {
"0to20": {
"today": 0,
"todate": 0
},
"20to40": {
"today": 0,
"todate": 0
},
"above100": {
"today": 0,
"todate": 0
}
}
}