如何解析json的每个元素,如{“response”:[{“result”:“rohit1”}]} {“response”:[{“result”:“rohit”}]} {“response”:[{“ 结果”:‘罗希特夏尔’}]}

I am new in the field of android, I want to access each result element from response json array but I am not able to do that I tried to get each element but I got only one value that is "rohit1" only which is first element. Please help me in this.

I am rohit parmar,computer science background, I tried lots of effort but not able to get each element of the json array.

try {
    JSONObject j1 = new JSONObject (s1);
    JSONArray j2 = j1.getJSONArray ("response");
    for (int i1 = 0; i1 < j2.length(); i1++) {
        JSONObject j3=j2.getJSONObject(i1);
        String s2 = j3.getString("result");
        a1.add("Active Users" ;
        a1.add(s2 );
        ArrayAdapter a2 = new ArrayAdapter(UserlistActivity.this, android.R.layout.simple_list_item_1, a1 );
        l1.setAdapter(a2 ;
    }
} catch(Exception e){
    e.printStackTrace();
}

When I tried to get each element of the json array from php with above code I got only first element but I want each element of the json array please suggest me right how to loop through whole json array.

It's because you have 3 elements with array inside and each of them contains 1 entry.

If I understand you right, your json should be

{
    "response":[
        {"result": "rohit1"},
        {"result": "rohit2"},
        {"result": "rohit3"}
    ]
}