title: Loop Foreach with JSONArray
body: <p>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.</p>
  <p>Exception java.lang.StringIndexOutOfBoundsException: String index out of range: 9</p>
  <pre><code>
  import com.oracle.e1.common.OrchestrationAttributes;
  import java.text.SimpleDateFormat;
  import groovy.json.*;
  import org.json.JSONArray;
  import org.json.JSONObject;
  
  HashMap&lt;String, Object&gt; main(OrchestrationAttributes orchAttr, HashMap inputMap)
  {
      HashMap&lt;String, Object&gt; returnMap = new HashMap&lt;String, Object&gt;();
      def ARDDataSet = [];
      String Grid_D = [{Transaction_Number=&quot;Transaction_1&quot;, Line_Number=&quot;1.000&quot;},
      {Transaction_Number=&quot;Transaction_2&quot;, Line_Number=&quot;2.000&quot;}];
      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(&quot;test&quot;, newDAR.Transaction_Number);
  }
  
  </code></pre>