That is a bad title but an example of what I am trying to do is below.
I have the following array of objects (3 in this example but could be any number).
objArray =
[
{
name : "My_Object_1",
values : ["bob","tom","phil"],
children : {
"bob":["terry","carl"],
"tom" : ["paul","kevin"],
"phil" : []
}
},
{
name : "My_Object_2",
values : ["terry","carl","paul","kevin"],
children : {
"terry":[],
"carl":[],
"paul":["jo","tim"],
"kevin":[]
}
},
{
name : "My_Object_3",
values : ["jo","tim"],
children:{}
}
]
I need to create a new array of objects for each combination if there is a child in the next object in the original array like this:
finalResult = [
{
"My_Object_1" : "phil",
"My_Object_2" : "",
"My_Object_3" : "",
},
{
"My_Object_1" : "bob",
"My_Object_2" : "terry",
"My_Object_3" : "",
},
{
"My_Object_1" : "bob",
"My_Object_2" : "carl",
"My_Object_3" : "",
},
{
"My_Object_1" : "tom",
"My_Object_2" : "kevin",
"My_Object_3" : "",
},
{
"My_Object_1" : "tom",
"My_Object_2" : "paul",
"My_Object_3" : "jo",
},
{
"My_Object_1" : "tom",
"My_Object_2" : "paul",
"My_Object_3" : "tim",
}
]
Any help would be great!