Given the following JSON
{
"Families": [
{ "Name": "Smith",
"Children": [
{ "Name": "Bob",
"Pets": [
{ "Name": "Oscar", "Type": "Cat"},
{ "Name": "Otto", "Type": "Dog"}
]
},
{ "Name": "Brittney",
"Pets": [
{ "Name": "Isolde", "Type": "Dog"},
{ "Name": "Ignatz", "Type": "Turtle"}
]
}
]
},
{ "Name": "Miller",
"Children": [
{ "Name": "Alex",
"Pets": [
{ "Name": "Elvis", "Type": "Horse"}
]
}
]
}
]
}
A) I'd like to create a query that yields the following structure
[
{ "FamilyName": "Smith",
"KidName": "Bob",
"Petname": "Oscar"
},
{ "FamilyName": "Smith",
"KidName": "Bob",
"Petname": "Otto"
},
{ "FamilyName": "Smith",
"KidName": "Brittney",
"Petname": "Isolde"
},
{ "FamilyName": "Smith",
"KidName": "Brittney",
"Petname": "Ignatz"
},
{ "FamilyName": "Miller",
"KidName": "Alex",
"Petname": "Elvis"
}
]
B) I'd like to create a query that yields this slightly different structure
[
{ "FamilyName": "Smith",
"KidName": "Bob",
"Petnames": ["Oscar", Otto"]
},
{ "FamilyName": "Smith",
"KidName": "Brittney",
"Petname": ["Isolde", "Ignatz"]
},
{ "FamilyName": "Miller",
"KidName": "Alex",
"Petname": ["Elvis"]
}
]
Your help is greatly appreciated
Robert