1

how can I fetch this response from URL in android?

 1. //main array   
                [
                         //array in main array     
                         [
                            //object in inner array 
                            {
                                //data to be fetched here 
                                "user_id": "8035",
                                "sr_no": "MG2459",
                                "user_type": "2",
                                "name": "Allen"

                            }
                        ],
                        //2nd array in main array 
                        [     
                            {
                                "user_id": "8035",
                                "sr_no": "MG2459",
                                "user_type": "2",
                                "name": "TestName"

                            }
                        ]


                ]
3

1 Answer 1

0

try below code :-

    try {
        JSONArray ja = new JSONArray(ur string);
        for (int i = 0; i < ja.length(); i++) 
        {
            JSONArray ja1 = ja.getJSONArray(i);
            for (int j = 0; j < ja1.length(); j++) {
                JSONObject jo = ja1.getJSONObject(j);
                String user_id = jo.getString("user_id");
                String sr_no = jo.getString("sr_no");
                String user_type = jo.getString("user_type");
                String name = jo.getString("name");
            }
        }
    } catch (Exception e) {
        // TODO: handle exception
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the immediate response.. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.