What is the code for take key-values from given json, We can use Hash Map? how to write the code?Need to change pojo class?I need to take 'startTime' and 'endTime' from JSON
My input Json
{
"active" : 0,
"id" : 3,
"doctorId" :8,
"hospitalId" : 55,
"timeSlot" : [
{ "startTime": "10",
"endTime": "12"
},
{ "startTime": "3",
"endTime": "5"
}
]
}
My code
List slot = customDuty.getTimeSlot();
int count = 0;
while (slot.size() > count) {
logger.info("checking"+slot.get(count));
count++;
}
PojoClass
private List timeSlot ;
public List getTimeSlot() {
return timeSlot;
}
public void setTimeSlot(List timeSlot) {
this.timeSlot = timeSlot;
}
output
checking{startTime=10, endTime=12}
checking{startTime=3, endTime=5}