title: parsing AggregationOutput mongo java driver
body: <p>I have an aggregate that returns 3 results</p>
  
  <pre><code>{ "serverUsed" : "/127.0.0.1:27017" , "result" : [ { "_id" : "luke" , "times" : 56} , { "_id" : "albert" , "times" : 28} , { "_id" : "matt" , "times" : 28}] , "ok" : 1.0}
  </code></pre>
  
  <p>however when I try to iterate over the results, the code enter an endless loop (can't understand why!!)</p>
  
  <pre><code>AggregationOutput output = coll.aggregate( match1, unwind, match2, group, sort, limit);
  
  Iterable&lt;DBObject&gt; list= output.results();
          while(list.iterator().hasNext()){
  
              String id = (String) list.iterator().next().get("_id");
              int times = Integer.parseInt(list.iterator().next().get("times").toString());
  
              System.out.println("ID IS "+id+" time: "+times);
          }
  </code></pre>
  
  <p>Also the output repeats the first result:</p>
  
  <pre><code>ID IS luke time: 56
  ID IS luke time: 56
  ID IS luke time: 56
  ID IS luke time: 56
  ID IS luke time: 56
  ...
  </code></pre>
  
  <p>I really don;t understand why this iteration is not working. Please help!</p>