this should work:
const all = [
{
"a": "Content A",
"b":
{
"1": "Content 1",
"2": "Content 2"
}
},
{
"y": "Content Y",
"x":
{
"3": "Content 3",
"4": "Content 4"
}
},
];
console.log(all.reduce((prev, el) =>{
let curr = Object.entries(el);
let k1 = curr[0][0];
let k2 = curr[1][0];
Object.entries(curr[1][1]).forEach((o => {
let obj ={}
obj[k1] = curr[0][1];
obj[k2] = o[1];
prev.push(obj);
}))
return prev;
},[]))
solved Array of objects containing objects to flat object array