title: Create json Object by java from data of mysql
body: <p>After getting data from mysql, I need to export data as JSON,like the format as follows:</p>
  
  <pre><code>{"Thong tin":[{"Ngay":"2013-06-18","Tinh":"An Giang"},{"Ngay":"2013-06-17","Tinh":"Bình Dương"},{"Ngay":"2013-06-16","Tinh":"Bạc Liêu"}]}
  </code></pre>
  
  <p>But what i get , it's like </p>
  
  <pre><code>{"Thong tin":[{"Ngay":"2013-06-16","Tinh":"Bạc Liêu"},{"Ngay":"2013-06-16","Tinh":"Bạc Liêu"},{"Ngay":"2013-06-16","Tinh":"Bạc Liêu"}]}
  </code></pre>
  
  <p>Can you help me fix this error?</p>
  
  <p>My code:</p>
  
  <pre><code>acc = new access();
      rs2 = acc.query("select province_Name, date_Expired from thong_tin_khach_hang");
      List&lt;String&gt; province_Name = new ArrayList&lt;String&gt;();
      List&lt;String&gt; date_Expired = new ArrayList&lt;String&gt;();
      try {
          while (rs2.next()) {
              province_Name.add(rs2.getString(1));
              date_Expired.add(rs2.getString(2));
          }
      } catch (SQLException e) {
          try {
              acc.con.close();
          } catch (SQLException e1) {
              e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
          }
      }
  
      JSONObject obj = new JSONObject();
      JSONArray jarray = new JSONArray();
      try {
          JSONObject ob = new JSONObject();
          for (int i = 0; i &lt; province_Name.size(); i++) {
              ob=new JSONObject();
              ob.put("Tinh", province_Name.get(i));
              ob.put("Ngay", date_Expired.get(i));
              jarray.add(ob);
          }
          obj.put("Thong tin", jarray);
      } catch (JSONException e) {
          e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
      }
      out.print(obj);
  </code></pre>