I have 2 arrays A and B:
"A": [{
"name": "test1",
"id": "build:jenkins>test1"
}, {
"name": "test2",
"id": "build:jenkins>test2"
}, {
"name": "maven",
"id": "build:maven"
}, {
"name": "maven1",
"id": "build:maven1"
}]
"B": [{
"name": "jenkins",
"id": "build:jenkins"
}, {
"name": "m1",
"id": "build:maven>m1"
}, {
"name": "m2",
"id": "build:maven>m2"
}, {
"name": "maven3",
"id": "build:maven3"
}]
I am trying to get a resultant array "C" which will search for available children in both the arrays based on the "id" and give an array as:
"C":
[{ "id": "build:jenkins",
"children":
[{"name": "test1","id": "build:jenkins>test1"},
{"name": "test2","id": "build:jenkins>test2"}
]
},
{ "id": "build:maven",
"children":
[{"name": "m1","id": "build:maven>m1"},
{"name": "m2","id": "build:maven>m2"}
]
},
{"id": "build:maven1","children":[]},
{"id": "build:maven3","children":[]}
]
I am trying to iterate through array A and then iterate through array B to get to the children based on the id but not able to do two way searching in both the arrays at the same time. Please help me get the result like array C.