I'm trying to get with Javascript JSON object values to be grouped based on the name key word in the array that contains the objects this is a dynamic array so this cannot be hard coded.
the objects have time values in it
the time_entries array length changes.
the time_entries array can have 1 or more objects in it.
I want to group the objects by the time: Hour minutes seconds
{
"activities": [
{
"name": "player one",
"time_entries": [
{
"days": 0,
"end_time": "2019-09-30 15:19:43",
"hours": 01,
"minutes": 02,
"seconds": 11,
"start_time": "2019-09-30 14:17:58"
},
{
"days": 0,
"end_time": "2019-09-25 15:40:11",
"hours": 0,
"minutes": 20,
"seconds": 4,
"start_time": "2019-09-25 15:20:15"
},
{
"days": 0,
"end_time": "2019-09-25 16:10:15",
"hours": 0,
"minutes": 30,
"seconds": 4,
"start_time": "2019-09-25 15:40:11"
},
#there can be more objects here
]
},
{
"name": "player two",
"time_entries": [
{
"days": 0,
"end_time": "2019-09-30 19:18:51",
"hours": 0,
"minutes": 0,
"seconds": 52,
"start_time": "2019-09-30 19:17:58"
},
#there can be more objects here
]
},
{
"name": "player three",
"time_entries": [
{
"days": 0,
"end_time": "2019-09-30 19:19:09",
"hours": 0,
"minutes": 0,
"seconds": 58,
"start_time": "2019-09-30 19:18:51"
},
{
"days": 0,
"end_time": "2019-09-30 21:21:09",
"hours": 2,
"minutes": 1,
"seconds": 0,
"start_time": "2019-09-30 19:20:09"
},
#there can be more objects here
]
}
]
}
What I want to get is something like this
[
{
"name": "player one",
"time_entries": [
{
"days": 0,
"end_time": "2019-09-25 16:10:15",
"hours": 01,
"minutes": 50,
"seconds": 19,
"start_time": "2019-09-30 14:17:58"
}
]
},
{
"name": "player two",
"time_entries": [
{
"days": 0,
"end_time": "2019-09-30 19:18:51",
"hours": 0,
"minutes": 0,
"seconds": 52,
"start_time": "2019-09-30 19:17:58"
}
]
},
{
"name": "player three",
"time_entries": [
{
"days": 0,
"end_time":"2019-09-30 21:21:09",
"hours": 2,
"minutes": 1,
"seconds": 58,
"start_time": "2019-09-30 19:18:51"
}
]
}
]