title: How to write a json to add a list?
body: <p>I need to create a json like this.</p>
  
  <pre><code>{
      "List": [
          {
              "Description": "ABC",
              "Id": "music",
              "Issent": "0"
          },
          {
              "Description": "ABC",
              "Id": "music",
              "Issent": "0"
          }
      ]
  }
  </code></pre>
  
  <p>this is the code which i'm using to write the json. But it does not display all the values which i'm getting through the database.It repeats the data from the last column of the database </p>
  
  <pre><code>JSONObject jo = new JSONObject();
  JSONArray ja = new JSONArray();
  
  Map&lt;String, Object&gt; data = new HashMap&lt;String, Object&gt;();
  
  try {
      Statement ac = DBL.getConnection().createStatement();
      ResultSet r5 = ac.executeQuery("Select * from msg");
      while (r5.next()) {
          System.out.println("Value taken from database" + r5.getString("content"));
  
          data.put("Description", r5.getString("content"));
          data.put("Id", r5.getString("id"));
          data.put("Issent",r5.getString("issent"));
  
          ja.put(jo);    
      }
      ja.put(data);
  
      System.out.println(data);
  
      JSONObject mainObj = new JSONObject();
  
      ret = mainObj.put("List", ja).toString();
  }
  </code></pre>