title: how to add a list of string into json object in jsp?
body: <p>I have written a program in jsp to insert values into database , now i want to retrieve those values from database and show it in json format.
  I have name , gender and age parameters and i am getting it in a list and i want to show it as
      Users{
      1:{name:abc,gender:male,age:21},2:{name:xyz,gender:female,age:25},......
      }</p>
  
  <p>My Jsp code</p>
  
  <pre><code>&lt;%
  PrintWriter outt = response.getWriter();
  JSONObject obj = new JSONObject();
  Insert_UserDetails details = new Insert_UserDetails();
  request.setCharacterEncoding("utf8");
  response.setContentType("application/json");
  List&lt;String&gt; list = details.getAllUsers();
  JSONArray jArray = new JSONArray();
  for (int i = 0; i &lt; list.size(); i++) {
      JSONObject formDetailsJson = new JSONObject();
      formDetailsJson.put("result", list.get(i));
      jArray.add(formDetailsJson);
  }
  
  obj.put("form_details", jArray);
  out.print(obj.toString());
  %&gt;
  </code></pre>
  
  <p>I am getting output as :</p>
  
  <pre><code>{"form_details":[{"result":"arjun"},{"result":"male"},{"result":"21"},  
  {"result":"ravi"},{"result":"male"},{"result":"30"},{"result":"pushpa"}, 
  {"result":"female"},{"result":"57"},{"result":"usha"},{"result":"female"},
  {"result":"60"},{"result":"bharat"},{"result":"male"},{"result":"30"},
  {"result":"ramesh"},{"result":"male"},{"result":"29"},{"result":"ramesh"},
  {"result":"male"},{"result":"29"}]}
  </code></pre>
  
  <p>I am new to json , so need some guidance 
  Thank You</p>