title: Why in my JSON array is just last json element?
body: <p>Why in my JSON array is just last json element?</p>
  
  <p>This is my code:</p>
  
  <pre><code>@GET
  @Path("inregistrareHarta")
  @Produces(MediaType.APPLICATION_JSON)
  public void getListPuncte(@QueryParam("idTransporturi") int idTransporturi) 
  {
    PuncteDAO puncteInformation = new PuncteDAO();
    ArrayList&lt;Puncte&gt; puncteList = puncteInformation.getPuncte(idTransporturi);
  
    Gson gson = new Gson();
    JsonArray arrayObj=new JsonArray();
    for(int i=0;i&lt;puncteList.size();i++)
    {
      Puncte puncte = puncteList.get(i);
      JsonElement puncteObj = gson.toJsonTree(puncte);   
      arrayObj.add(puncteObj);
    }
    JsonObject myObj = new JsonObject();
    myObj.add("puncteList", arrayObj);
    System.out.println(myObj.toString());
  }
  </code></pre>
  
  <p>This is the result I'm getting:</p>
  
  <pre><code>{"puncteList":
    [
      {"idPuncte":7,"idTransport":2,"latitudine":190.0,"longitudine":150.0,"descriere":"2_4"},
      {"idPuncte":7,"idTransport":2,"latitudine":190.0,"longitudine":150.0,"descriere":"2_4"},
      {"idPuncte":7,"idTransport":2,"latitudine":190.0,"longitudine":150.0,"descriere":"2_4"},
      {"idPuncte":7,"idTransport":2,"latitudine":190.0,"longitudine":150.0,"descriere":"2_4"}
    ]
  }
  </code></pre>
  
  <p>And this is the result I'm expecting:</p>
  
  <pre><code>{"puncteList":
    [ 
      {"idPuncte":4,"idTransport":2,"latitudine":19.0,"longitudine":0.0,"descriere": "‌2_1"}, 
      {"idPuncte":5,"idTransport":2,"latitudine":10.0,"longitudine": 50.0,"descriere":"‌2_2"}, 
      {"idPuncte":6,"idTransport":2,"latitudine":1.0,"longitudine":1.0,"descriere":"2_‌3"},
      {"idPuncte":7,"idTransport":2,"latitudine":30.0,"longitudine":50.0,"descriere":"‌2_4"}
    ]
  }
  </code></pre>