I want to generate the following form

```
{
"dt": {
    "DocumentElement": [

            {
                "CompanyID": "8",
                "Question": "Who I M?",
                "Answer": "dfsfdsfd"

        },
        {

                "CompanyID": "8",
                "Question": "Who I M?",
                "Answer": "Chintan"

        }
    ]
  }
}

```

I have one arraylist which is dynamically filled with data and i also want the form in terms of dynamic. Here is my code: 

```
JSONObject DocumentElementobj = new JSONObject();
        JSONArray req = new JSONArray();

        JSONObject reqObj = new JSONObject();
        try {
            for (int i = 0; i < OnLineApplication.mParserResults.size(); i++) {

                reqObj.put("CompanyID", "8");
                reqObj.put("Question",OnLineApplication.mParserResults.get(i).getQuestion());
                reqObj.put("Answer",OnLineApplication.mParserResults.get(i).getAnswer());

            }

            DocumentElementobj.put( "DocumentElement", req );
            System.out.println("Final "+DocumentElementobj.toString());
        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

```

It outputs:
 Final {"DocumentElement":[]}

**EDIT**

Thanks to all your response. As per you all responce i make code like below

```
JSONObject DocumentElementobj = new JSONObject();
        JSONArray req = new JSONArray();
        JSONObject reqObjdt = new JSONObject();

        try {
            for (int i = 0; i < OnLineApplication.mParserResults.size(); i++) {

                JSONObject reqObj = new JSONObject();
                reqObj.put("CompanyID",   OnLineApplication.mParserResults.get(i).getCompanyId());
                reqObj.put("Question",OnLineApplication.mParserResults.get(i).getQuestion());
                reqObj.put("Answer",OnLineApplication.mParserResults.get(i).getAnswer());
                req.put(reqObj);

            }

            DocumentElementobj.put( "DocumentElement", req );
            reqObjdt.put("dt", DocumentElementobj);
            System.out.println("Final "+reqObjdt.toString());
        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

```

**I get foramt which i want but in final string i get sequeence like below**

```
{"dt":
  {"DocumentElement":
    [
    {"Answer": "The Claims Representatives have a small role in return to  work.","Question":"Return-to-Work Claim Issues. Please check the statement that best  applies.","CompanyID":"8"},
    {"Answer":"Poor","Question":"How would you describe the level of your general employee’s understanding of the impact of workers’ compensation costs on your organization?","CompanyID":"8"}]}}

```

it comes Answer first in sequence but i want to CompanyID first so what is issue in that?