I have a data array like below which needs to be a structured by using Value property with Start and End Time
[{
"Timestamp": "2021-09-30T21:38:46.7000122Z",
"Value": "496",
},
{
"Timestamp": "2021-10-01T01:08:47.4690093Z",
"Value": "496",
},
{
"Timestamp": "2021-10-02T15:38:02.5080108Z",
"Value": "207",
},
{
"Timestamp": "2021-10-02T16:30:32.3410034Z",
"Value": "207",
},
{
"Timestamp": "2021-10-02T21:45:32.7460021Z",
"Value": "207",
},
{
"Timestamp": "2021-10-02T22:38:02.5839996Z",
"Value": "413",
},
{
"Timestamp": "2021-10-02T23:30:33.3980102Z",
"Value": "413",
},
{
"Timestamp": "2021-10-03T00:23:02.7130126Z",
"Value": "413",
},
{
"Timestamp": "2021-10-03T11:47:47.8630065Z",
"Value": "413",
}]
Is there a way to compose the above array to into below format like group using Value and pick the the 1st object timestamp as Start Time and last object timestamp value as End Time like below
[{
"id": 496
"stTime": "2021-09-30T21:38:46.7000122Z"
"endTime": "2021-10-01T01:08:47.4690093Z"
},{
"id": 207
"stTime": "2021-10-02T15:38:02.5080108Z"
"endTime": "2021-10-02T21:45:32.7460021Z"
},{
"id": 413
"stTime": "2021-10-02T22:38:02.5839996Z"
"endTime": "2021-10-03T11:47:47.8630065Z"
}]