I have 2 arrays in Java with different Array names (sender and recipient), but the variables within the arrays are the same (account_number, product_id, external_id, simulation, recipient_sms_notification, sender_sms_notification), when declaring them I must call them variables within the arrays, how do I call it and be able to distinguish between them?
String message;
JSONObject json = new JSONObject();
json.put("account_number",account_number);
json.put("product_id", product_id);
json.put("external_id", external_id);
json.put("simulation", simulation);
json.put("recipient_sms_notification", recipient_sms_notification);
json.put("sender_sms_notification", sender_sms_notification);
JSONArray array = new JSONArray();
JSONObject item = new JSONObject();
item.put("last_name", last_name);
item.put("middle_name", middle_name);
item.put("first_name", first_name);
item.put("email", email);
item.put("mobile", mobile);
array.put(item);
json.put("sender", array);
JSONArray array2 = new JSONArray();
JSONObject item2 = new JSONObject();
item.put("last_name", last_name);
item.put("middle_name", middle_name);
item.put("first_name", first_name);
item.put("email", email);
item.put("mobile", mobile);
array.put(item);
json.put("recipient", array);
message = json.toString();