title: How to add object to JSONArray
body: <p>I want to add an object to an array. If the data of <code>other_amount</code> is more than zero I want to add one object more. If it's equal to zero, it should add nothing. This is my code:</p>
  
  <pre><code>JSONArray acc_data = new JSONArray();
  Map&lt;String, Object&gt; myaccount = new LinkedHashMap&lt;&gt;();
  for (int i = 0; i &lt; mpay.size(); i++) {
      if(other_amount&gt;0){
          myaccount.put("poAccount", other_account);
          myaccount.put("poAmount", other_amount);
          system.out.println(myaccount);
          //{poAccount=050017, poAmount=12}
      }
  
      myaccount.put("poAccount", amount_account);
      myaccount.put("poAmount", amount);
      system.out.println(myaccount);
      //{"poAccount":"050016","poAmount":"800"}
  
      acc_data.add(myaccount);
      system.out.println(acc_data);
      //[{"poAccount":"050016","poAmount":"800"}]
  }
  </code></pre>
  
  <p>But I need it like this: </p>
  
  <pre><code>//[{"poAccount":"050016","poAmount":"800"},{poAccount=050017, poAmount=12}]
  </code></pre>
  
  <p>please help me to resolve it.</p>