JSONObject jsonObject = new JSONObject();
try {
//Settings up array
JSONArray jArry = new JSONArray();
//this arraylist is contains of arraylist with tagIDs
ArrayList<InventoryListItem> arr = Application.tagsReadInventory;
int position = 0;
//this arraylist is where i put my collected tagIDs from "Application.tagsReadInventory"
ArrayList<String> tagIDs = new ArrayList<>();
//looping to get tagIDs from "Application.tagsReadInventory" and put it in tagIDs arraylist
for (position = 0; position < arr.size(); position++) {
tagIDs.add(arr.get(position).getTagID());
}
//get each of the list inside tagIDs arraylist
for (String tags : tagIDs) {
JSONObject jObj = new JSONObject();
jObj.put("epc",tags);
jObj.put("antennaPort", 1);
jArry.put(jObj);
}
jsonObject.put("reader_name", ReaderIP);
jsonObject.put("mac_address", "asd");
jsonObject.put("tag_reads", jArry);
} catch (JSONException e) {
e.printStackTrace();
}