'Loop Foreach with JSONArray

I was trying to loop the array using for each, but I am unsure of the exact method. At the moment, system throws me an error string index out of range: 9. May I know if there is a proper method for this.

Exception java.lang.StringIndexOutOfBoundsException: String index out of range: 9


import com.oracle.e1.common.OrchestrationAttributes;
import java.text.SimpleDateFormat;
import groovy.json.*;
import org.json.JSONArray;
import org.json.JSONObject;

HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
    HashMap<String, Object> returnMap = new HashMap<String, Object>();
    def ARDDataSet = [];
    String Grid_D = [{Transaction_Number="Transaction_1", Line_Number="1.000"},
    {Transaction_Number="Transaction_2", Line_Number="2.000"}];
    def jsonslurper = new JsonSlurper(); 
    def GridJSON2 = jsonslurper.parseText(Grid_D);
      for (def Dmember : GridJSON2){
            def newDAR = [:]
            newDAR.Transaction_Number = Dmember.Transaction_Number;
            ARDDataSet.push(newDAR);
      }
      returnMap.put("test", newDAR.Transaction_Number);
}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source