I am getting a Json response as below:
{
messages: [
{
id: "83",
payer_id: "5",
payee_id: "24",
payer_name: "vishal ",
payee_name: "ravi ",
payer_image: "upload/123.jpg",
payee_image: "upload/crop_110x110_1338731270_591178.jpg",
dispute_id: "43",
subject: "",
message_body: "dwedwde",
added_on: "2014-01-16 04:06:35",
sender_id: "5",
read: "1"
},
{
id: "716",
payer_id: "5",
payee_id: "6",
payer_name: "vishal ",
payee_name: "vishal ",
payer_image: "upload/123.jpg",
payee_image: "upload/yt.png",
dispute_id: "43",
subject: "",
message_body: "smthig",
added_on: "2014-05-27 02:26:04",
sender_id: "6",
read: "1"
}
],
status: "success"
}
I have coded as below for parsing.
ArrayList<HashMap<String, String>> msgList;
msgList = new ArrayList<HashMap<String, String>>();
String jsonStr = sh.makeServiceCall(disputeURL, BackendAPIService.GET);
Log.print("Response: ", "> " + jsonStr);
try {
if (jsonStr != null) {
jsonObj = new JSONObject(jsonStr);
if (jsonObj.has(Const.TAG_MESSAGES)) {
System.out.println(":::::::::::::has::::::::::::");
msgArray = jsonObj.getJSONArray(Const.TAG_MESSAGES);
if (msgArray != null && msgArray.length() != 0) {
// looping through All Contacts
for (int i = 0; i < msgArray.length(); i++) {
System.out.println("::::::::::::ARRAY:::::::::::");
JSONObject c = msgArray.getJSONObject(i);
id = c.getString("id");
payee_id = c.getString("payee_id");
payer_id = c.getString("payer_id");
payer_name = c.getString("payer_name");
payee_name = c.getString("payee_name");
payer_image = c.getString("payer_image");
payee_image = c.getString("payee_image");
dispute_id = c.getString("dispute_id");
subject = c.getString("subject");
message_body = c.getString("message_body");
added_on = c.getString("added_on");
sender_id = c.getString("sender_id");
read = c.getString("read");
dispute_id = c.getString(Const.TAG_DIPUTE_ID);
System.out.println("::::::::::::sender Id::::::::::" + sender_id + ":::::::::::::::");
System.out.println("::::::::::::payee ID::::::::::" + payee_id + ":::::::::::::::");
HashMap<String, String> disputeMsgMap = new HashMap<String, String>();
disputeMsgMap.put(Const.TAG_ID, id);
disputeMsgMap.put(Const.TAG_PAYEE_ID, payee_id);
disputeMsgMap.put(Const.TAG_PAYER_ID, payer_id);
disputeMsgMap.put(Const.TAG_PAYER_NAME, payer_name);
disputeMsgMap.put(Const.TAG_PAYEE_NAME, payee_name);
disputeMsgMap.put(Const.TAG_PAYER_IMAGE, payer_image);
disputeMsgMap.put(Const.TAG_PAYEE_IMAGE, payee_image);
disputeMsgMap.put(Const.TAG_DIPUTE_ID, dispute_id);
disputeMsgMap.put(Const.TAG_SUBJECT, subject);
disputeMsgMap.put(Const.TAG_MESSAGE_BODY, message_body);
disputeMsgMap.put(Const.TAG_ADDED_ON, added_on);
disputeMsgMap.put(Const.TAG_READ, read);
disputeMsgMap.put(Const.TAG_SENDER_ID, sender_id);
msgList.add(disputeMsgMap);
}
}
So, I want to check that "sender_Id" of JSONObjects are different or not; I just want to check weather sender_id of any object is different or all are same.