How to recover a multidimensional array with json in Android

advertisements

I have a multidimensional array that I want to retrieve using JSON in android. I have the following JSON Structure for this :

  [
      [
        {
          "name": "Banking",
          "data": [
            {
              "vendor_name": "SBI",
              "vendor_id": "1"
            },
            {
              "vendor_name": "ICICI",
              "vendor_id": "2"
            },
            {
              "vendor_name": "BOB",
              "vendor_id": "3"
            }
          ],
          "count": 4
        }
     ]
 ]

I want to get "name",vendor_name,vendor_id in my Strings in android. But I am not getting idea how to do this. Please let me know how to retrieve this.


     try {
            jsonObj = new JSONObject(YourString);
        } catch (JSONException e) {
            Log.v("Error in Parser", " " + e);
        }
    try{

     String name=jsonObj.getString("name");
            Data = jsonObj.getJSONArray("data");
                for (int i = 0; i < Data.length(); i++) {
                        JSONObject jsonObj2 = Data.getJSONObject(j);
                        String vName = jsonObj2.getString("vendor_name");
                        String vId=jsonObj2.getString("vendor_id");
                }
}catch(Exception e)
{
}