I am seeking solutions to restructure an object that has multiple arrays of objects so that I can access the object directly.
console.log(value.data.summary[0].data)
Instead of accessing arrays in this manner, I want to modify my data structure. Is there a way to create an object similar to the 'result' object where nested array of objects can be accessed directly?
I aim to establish a result object that allows for direct access to the nested array of objects.
let value = {
"data":{
"summary":[
{
"code":"9280",
"data":[
{
"val1":"test1",
"val2":"CAD",
"val3":0,
},
{
"val1":"test2",
"val2":"USD",
"val3":0,
},
]
},
]
}
}
let result = {
"data": {
"code":"9280",
"summary":[
{
"val1":"test1",
"val2":"CAD",
"val3":0,
},
{
"val1":"test2",
"val2":"USD",
"val3":0,
},
]
}
}