I would like to extract into two separate array the key "desc" and "type" in my JSON file. I get the file from an ftp site and I don't know how many entry there are. After I have the String Array, I would like to fill a Spinner by the "desc" value. How can do that?
this is my JSON file
{
"Pagnerine":[{
"Cialda":[{
"userId":1,
"desc":"Sottozero/Estate",
"type":"ct"
},
{
"userId":2,
"desc":"Piccolo/Primavera",
"type":"ct"
},
{
"userId":3,
"desc":"Medio",
"type":"ct"
},
{
"userId":4,
"desc":"Grande",
"type":"ct"
}
],
"Cartone":[{
"userId":1,
"desc":"16B",
"type":"ct"
},
{
"userId":2,
"desc":"17",
"type":"ct"
},
{
"userId":3,
"desc":"34",
"type":"ct"
},
{
"userId":4,
"desc":"20",
"type":"ct"
}
]
}
],
"Cucchiaini":[],
"Vaschette":[],
"Zuccheri":[],
"versione":"100"
}
i have tried to implement this code for obtain how many entry (desc or type) there are, but fail because count only the first part "Cialda" and "Cartone"
Iterator<String> iter = jObj.keys();
while (iter.hasNext()) {
String key = iter.next();
try {
JSONArray jArray = jObj.getJSONArray(key);
// looping through
entry += jArray.length();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}