Basically I have a json array and I want to create a new array in which I want to push all childNode and inside ChildNode its respective funding source name
var data = vardata={
"costdata": [
{
fundingSource: 'A',
childNode: [
{
childName: 'x',
amt: 100
}
]
},
{
fundingSource: 'B',
childNode: [
{
childName: 'y',
amt: 200
}
]
}
]
}
Expected output is to create single json array and pushed funding source element inside respective childNode attributes
vardata={
"costdata": [
{
childNode: [
{
fundingSource: 'A',
childName: 'x',
amt: 100
}
]
},
{
childNode: [
{
fundingSource: 'B',
childName: 'y',
amt: 200
}
]
}
]
}