I have a json array in this format:
{
"workHours":[{
"dayOfWeek":[1,2,3,4,5],
"timeInterval":"00:00-00:45"
},
{
"dayOfWeek":[5,6,0],
"timeInterval":"01:00-03:15"
},
{
"dayOfWeek":[6,0],
"timeInterval":"00:00-00:45"
}]
}
I would like to compare two conditions First I want to check each "dayOfWeek" and check if there are repeated day, for example, the first and second "dayOfWeek" both has a 5, second and third "dayOfWeek" both has 6 and 0. Second I want to check is "timeInterval" is the same, for example the first and third "timeInterval are both "00:00-00:45".
I can now get each object separately but I am not sure how to compare them one by one
for(int i = 0; i<array.length(); i++) {
JSONObject json = null;
try{
json = array.getJSONObject(i);
JSONArray dayOfWeekArr = json.getJSONArray("dayOfWeek");
String timeInterval = json.getString("timeInterval");
} catch (JSONException e) {
e.printStackTrace();
}
}