Код: Выделить всё
JSONArray acc_data = new JSONArray();
Map myaccount = new LinkedHashMap();
for (int i = 0; i < mpay.size(); i++) {
if(other_amount>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"}]
}
Код: Выделить всё
//[{"poAccount":"050016","poAmount":"800"},{poAccount=050017, poAmount=12}]
Подробнее здесь: https://stackoverflow.com/questions/500 ... -jsonarray