I have a unique situation where I have to get certain times from a json's deeply nested object. It's a little complex, I couldn't find a solution so looking for ideas and ways to tackle this
I have a the json as follows:
[{
"mySpaceId": 73220,
"myBuildingId": 14019,
"myFloorId": 10569,
"myFloorNumber": "4",
"myFloorName": "4th Floor",
"spaceName": "My Room 4",
"capacity": 5,
"type": "huddle",
"busyAt": []
},
{
"mySpaceId": 73219,
"myBuildingId": 14019,
"myFloorId": 10569,
"myFloorNumber": "4",
"myFloorName": "4th Floor",
"spaceName": "My room 5",
"description": null,
"capacity": 4,
"type": "huddle",
"timeZone": "America/New_York",
"busyAt": [{
"from": "2019-06-07T23:00:00+0000",
"to": "2019-06-07T23:15:00+0000",
"events": [{
"id": "109142028",
"series_id": null,
"recurrence_id": null,
"uid": "ABCDE",
"space_id": 73219,
"start": {
"date_time": "2019-06-07T19:00:00-0400",
"time_zone": "America/New_York"
},
"end": {
"date_time": "2019-06-07T19:15:00-0400",
"time_zone": "America/New_York"
},
"started_at": "2019-06-07T19:00:00-0400",
"ended_at": "2019-06-07T19:15:00-0400"
}]
}]
}
]
I use this : http://www.jsonschema2pojo.org/ to generate a class from the above json string. I was wondering how do I retrieve the "started_at": "2019-06-07T19:00:00-0400",
from busyAt-> events into my main model class generated by the above site? Say at the same level as mySpaceId. I currently use the following :
public List<BusyAt> getBusyAt() {
return busyAt;
}
public void setBusyAt(List<BusyAt> busyAt) {
this.busyAt = busyAt;
}
Is there a way I can retrieve the started_at at this level and parse the date and time in the format : 8:00 am ? to use it in my code.
Any idea how to go about this? Thanks! Please let me know if this is confusing or need more clarification, happy to post more code.