Q:

unable to parse json array with in json object

i am not able to read json data and bind into list view in andord.list view is display but values of doctype is always shows with v4.could you tell me what i did wrong with code.i am attaching code of parsing json data.
[
{
id: "HT20140109105317640",
basePath: "D:\img",
lstDocType: [
{
doctype: "PP1",
imageName: "CH100610_002_003_PP1.jpg",
imageupload: false
},
{
doctype: "PP2",
imageName: "CH100610_002_003_PP2.jpg",
imageupload: false
},
{
doctype: "V1",
imageName: "CH100610_002_003_V1.jpg",
imageupload: false
},
{
doctype: "V2",
imageName: "CH100610_002_003_V2.jpg",
imageupload: false
},
{
doctype: "V3",
imageName: "CH100610_002_003_V3.jpg",
imageupload: false
},
{
doctype: "V4",
imageName: "CH100610_002_003_V4.jpg",
imageupload: false
}
],
f_FNAME: "SANJAY",
f_FORM: "002",
f_TCD: "CH100610",
f_TNO: "003",
f_LNAME: "NANKANI"
},
{},
{},
{},
{},
{},
{},
{},
{},
{}
]

Here is code of parsing json data
public class DisplayList extends AsyncTask<String, String, String>
    {

        @Override
        protected void onPreExecute() 
        {
            // TODO Auto-generated method stub
            super.onPreExecute();
            pd=new ProgressDialog(MainActivity.this);
            pd.setMessage("Please Wait List Is Loading");
            pd.setCancelable(false);
            pd.show();

        }

        @Override
        protected String doInBackground(String... params)
        {
            // TODO Auto-generated method stub
            try
            {
                // create instance of json data class
                TourList tl=new TourList();
                jarray=tl.getJsonFromUrl("http://192.168.1.239:8080/VisaDocUpload/historycon/selectbycount/0/10");
                for(int i=0;i<jarray.length();i++)
                {
                    HashMap<String,String> map=new HashMap<String,String>();
                    JSONObject c=jarray.getJSONObject(i);
                    id=c.getString(KEY_ID);

                    JSONArray doct=c.getJSONArray("lstDocType");
                    for(int j=0;j<doct.length();j++)
                    {
                        JSONObject jo=doct.getJSONObject(j);
                        doctype=jo.getString(KEY_DOCTYPE);

                    }

                    map.put(KEY_ID,id);
                    map.put(KEY_DOCTYPE,doctype);
                    arraylist.add(map);
                }

            }
            catch(Exception e)
            {
                Log.d("In Back","");
            }
            return null;
        }

        @Override
        protected void onPostExecute(String result) 
        {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            pd.dismiss();
            lv.setAdapter(new MyTourDisplay(MainActivity.this,arraylist));
            Toast.makeText(getApplicationContext(), ""+id+doctype,Toast.LENGTH_LONG).show();

        }

    }

A:

The parsing is correct, the problem is related to the fact that you are only assigning doctype inside the more inner for loop so, inside the map, you are putting the last value you assign to doctype
private class Holder {
  public ArrayList<String>() docLst;
  // possible more kind of elements
}

and then:
Holder holder = new Holder();  
holder.docLst = new ArrayList<String>();

for(int j=0;j<doct.length();j++) {
     JSONObject jo=doct.getJSONObject(j);
     doctype=jo.getString(KEY_DOCTYPE);
     holder.docLst.add(doctype);
 }

 map.put(id, holder);

of course your HashMap have to be of the type <String, Holder>

