I have attached the code snippets for java script as following. I want to swap the particular index into the nested array. Following are code snippets for that,
const arr = [
{"ADMIN":[{"id":0,"name":"name"}],"id":"32323"},
{"id":"323","SECURITY NAME":[{"id":1,"name":"name"}]},
{"id":"32","SECURITY A2":[{"id":1,"name":"name"}]}]
for (let s = 0; s < arr.length; s++) {
const element =Object.keys(arr[s])[0];
console.log(typeof element)
}
I want second and third index of the array like the same one as first one. so inside structure is like first index should Key with array and second will be id.
so final output would be like
const arr = [
{"ADMIN":[{"id":0,"name":"name"}],"id":"32323"},
{"SECURITY NAME":[{"id":1,"name":"name"}],"id":"323"},
{"SECURITY A2":[{"id":1,"name":"name"}],"id":"32"}]
Thanks