Loop Json array with gson
<p>Im trying to parse a jsonObject and can't seem to get it, here is what i got.</p>

<pre><code> json = (json data)
 JsonParser parser = new JsonParser();
 JsonObject rootObj = parser.parse(json).getAsJsonObject();
 JsonObject paymentsObject = rootObj.getAsJsonObject("payments");

 for(JsonObject pa : paymentsObject){
        String dateEntered = pa.getAsJsonObject().get("date_entered").toString();
    }
</code></pre>

<p>But i get a foreach not applicable to type what am i missing. I've tried different ways but can't seem to get it. thanks</p>

<p>Json</p>

<pre><code> {
 "Name":"Test 2",
 "amountCollected":"1997",
 "payments":[
  {
     "quoteid":"96a064b9-3437-d536-fe12-56a9caf5d881",
     "date_entered":"2016-05-06 08:33:48",
     "amount":"1962",         
  },
  {
     "quoteid":"96a064b9-3437-d536-fe12-56a9caf5d881",
     "date_entered":"2016-05-06 08:33:08",
     "amount":"15",         
  },
  {
     "quoteid":"96a064b9-3437-d536-fe12-56a9caf5d881",
     "date_entered":"2016-05-06 03:19:08",
     "amount":"20",         
  }
 ]
}
</code></pre>