这是我的 JSON
数组,
[{
"textinput": [{
"position": 0,
"dependency": "no",
"id": 0,
"label": "single1",
"Itype": "textinput"
}, {
"position": 1,
"dependency": "no",
"id": 1,
"label": "single2",
"Itype": "textinput"
}, {
"position": 2,
"dependency": "no",
"id": 2,
"label": "single3",
"Itype": "textinput"
}, {
"position": 3,
"dependency": "no",
"id": 3,
"label": "single4",
"Itype": "textinput"
}, {
"position": 4,
"dependency": "no",
"id": 4,
"label": "single5",
"Itype": "textinput"
}, {
"position": 5,
"dependency": "no",
"id": 5,
"label": "single6",
"Itype": "textinput"
}]
}]
我想获得有关计算上述数组中 position
数量的帮助。
最佳答案
你错过了 j :P
try {
JSONArray jsonArray = new JSONArray("Your response");
int count = jsonArray.getJSONObject(0).getJSONArray("textinput").length();
} catch (JSONException e) {
e.printStackTrace();
}
关于android - json 数组中元素的计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38628193/