Using this Methode for each item if we have different key values, we can get the start with letters and change the key to the objects for all the item details.
if (itemImagesDetail) {
for (const key in itemImagesDetail) {
if (itemImagesDetail.hasOwnProperty(key) && key.startsWith('FM')) {
const imageid = itemImagesDetail[key];
const newKey = 'imageid';
delete itemImagesDetail[key];
itemImagesDetail[newKey] = imageid;
}
}
}