title: How to convert ArrayLIst items into json objects in Android
body: <p>I have two array List I want to convert items of array list into json objects &amp; then add those json objects into array list.</p>
  
  <p><strong>Json objects &amp; array</strong></p>
  
  <pre><code>     JSONObject jobj_id=new JSONObject();
       JSONObject jobj_ans=new JSONObject();
       JSONArray qhis_jar=new JSONArray();
  </code></pre>
  
  <p><strong>code for converting arraylist to json</strong> </p>
  
  <pre><code> for(int i=0;i&lt;arr_quesid.size();i++)
       {
           try {
  
              jobj_id.put("ques_id", arr_quesid.get(i));
              qhis_jar.put(jobj_id);
              jobj_ans.put("ans", arr_ans.get(i));
              qhis_jar.put(jobj_ans);
  
  
          } catch (JSONException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
       }
  </code></pre>
  
  <p>But I am getting only the last element of arraylist as json objects.</p>
  
  <pre><code>[{"ques_id":"questionId_7"},{"ques_name":"ans_7"},{"ques_id":"questionId_7"},{"ques_name":"ans_7"},{"ques_id":"questionId_7"},{"ques_name":"ans_7"},{"ques_id":"questionId_7"},{"ques_name":"ans_7"},{"ques_id":"questionId_7"},{"ques_name":"ans_7"},{"ques_id":"questionId_7"},{"ques_name":"ans_7"},{"ques_id":"questionId_7"},{"ques_name":"ans_7"}]
  </code></pre>
  
  <p>Please tell</p>