I have a large array of json objects, that I need to iterate through and add them to another json array.
The array looks like the following -
{
id : 1,
name : "test1",
location : "London",
cost: "120.83"
},
{
id : 2,
name : "test2",
location : "shanghai",
cost: "124.83"
},
{
id : 3,
name : "test3",
location : "Barcelona",
cost: "56.54"
}
The actual array that im using has 73 key, value pairs, and about 20000 objects.
I am trying to transpose each individual object into another array, that needs to look like -
{
cells:
[
{
value: 1,
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
{
value: "test1",
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
{
value: "London",
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
{
value: "120.83",
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
]
},
{
cells:
[
{
value: 2,
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
{
value: "test2",
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
{
value: "shanghai",
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
{
value: "124.83",
textAlign: "center",
background: "rgb(255,255,255)",
color: "rgb(0,62,117)"
},
]
},
I just cant get my head around it, it must be the monday fog!
Thanks