title: How to add data into a json array instead of a ArrayList?
body: <p>What I am trying to do is add a Map into an <code>ArrayList</code> and then into a <code>JsonArray</code>. What I intend to do is directly add the maps into the json array. </p>
  
  <pre><code>//Initialize the ArrayList,Map and Json array
  private ArrayList&lt;Map&lt;String, String&gt;&gt; itemData = new ArrayList&lt;&gt;();
  private Map&lt;String, String&gt; itemselected = new HashMap&lt;&gt;();
  JSONArray itemSelectedJson = new JSONArray();
  
  
  
   private void selectedItems() {
      if(invEstSwitch.isChecked())
      {
          billType = textViewEstimate.getText().toString();
      }else{
          billType = textViewInvoice.getText().toString();
      }
  
      itemselected.put("custInfo",custSelected.toString());
      itemselected.put("invoiceNo", textViewInvNo.getText().toString());
      itemselected.put("barcode", barCode.getText().toString());
      itemselected.put("desc", itemDesc.getText().toString());
      itemselected.put("weight", weightLine.getText().toString());
      itemselected.put("rate", rateAmount.getText().toString());
      itemselected.put("makingAmt", makingAmount.getText().toString());
      itemselected.put("net_rate", netRate.getText().toString());
      itemselected.put("itemTotal", itemtotal.getText().toString());
      itemselected.put("vat", textViewVat.getText().toString());
      itemselected.put("sum_total", textViewSum.getText().toString());
      itemselected.put("bill_type", billType);
      itemselected.put("date", textViewCurrentDate.getText().toString());
  
      //Add the map to the Array
      itemData.add(index, itemselected);
      itemSelectedJson= new JSONArray(Arrays.asList(itemData));
      index++;
  }
  </code></pre>