{
TX1: [ 1 , 2 , 3 ],
TX2: ["one", "two", "three" ],
TX3: ["blue", "red", "green"]
}
[
{
TX1: 1,
TX2: "one",
TX3: "blue"
},
{
TX1: 2,
TX2: "two",
TX3: "red"
},
{
TX1: 3,
TX2: "three",
TX3: "green"
},
]
const arr = Object
.entries(obj)
.reduce((acc, [ k, values ]) => (
values.forEach((v, i) => (acc[i] ??= {})[k] = v),
acc
), []);
const keys = Object.keys(obj);
const arr = obj[keys[0]]?.map((_, i) => {
return Object.fromEntries(keys.map(k => [ k, obj[k][i] ]));
}) ?? [];