2016-07-28 11 views
1

これは私のJSON配列、私は上記の配列にpositionの数をカウントしてヘルプを取得したいと思いカウント

[{ 
    "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" 
    }] 
}] 

+0

ポジション数がjsonarray.length .... –

+0

ポジションの合計を取得したいのは何ですか?もしそうでなければ、jsonArraylengthが必要です。 –

+0

ない総和が、どのように多くの「位置」その後、あなたの全体のJSONを入れ –

答えて

1

そこJを逃し:P

try { 
    JSONArray jsonArray = new JSONArray("Your response");  
    int count = jsonArray.getJSONObject(0).getJSONArray("textinput").length(); 
} catch (JSONException e) { 
    e.printStackTrace(); 
} 
0

のString []配列= text.split( "位置")。 //テキストあなたREPONSE JSON文字列

int型のカウント= Array.lengthと-1; //ポジション数