I have multiple arrays and I want to merge the data of all the array into one array of objects . All the data will be merged on the basis of the key so how to make one production level code so that it will merge all the data.
results[0]=
[ {categoryGroupID: '1231',categoryID: '12311',categoryName: 'External'},
{categoryGroupID: '1231',categoryID: '12312',categoryName: 'Internal'},
{categoryGroupID: '1231',categoryID: '141414141',categoryName: ''},
{categoryGroupID: '1232',categoryID: '12321',categoryName: 'Style'},
{categoryGroupID: '1233',categoryID: '123222',categoryName: ''},
{categoryGroupID: '1233',categoryID: '12331',categoryName: 'Customer Satisfaction'}]
results[1]=
[ { categoryGroupID: '1231',categoryGroupName: 'Store ambience'},
{ categoryGroupID: '1232',categoryGroupName: 'Communication'},
{categoryGroupID: '1233',categoryGroupName: 'Overall Satisfaction'},
{categoryGroupID: '12331',categoryGroupName: null}]
results[2]=
[ {categoryID: '12311',questionID: '12311111',questionName: 'tell me snything'},
{categoryID: '12312',questionID: '12311113',questionName: 'whatever'},
{categoryID: '12311',questionID: '123ques',questionName: 'ashjsh'},
{categoryID: '12311',questionID: '123test',questionName: null}]
results[3]=
[ { questionID: '12311113',choiceID: '1231111111',choiceValue: 'good'},
{ questionID: '12311113',choiceID: '1231111112',choiceValue: 'very good'},
{questionID: '12311113',choiceID: '12311113113',choiceValue: 'bad'}]
MY output should like this so how to do it
"categoryGroup":
[
{"categoryGroupID": "1231","categoryGroupName": "Store ambience",
"category": [
{"categoryID": "12312","categoryName": "Internal",
"question": [
{"questionID": "12311113","questionName": "whatever",
"choice": [
{"choiceID": "1231111111","choiceValue": "good"},
{"choiceID": "1231111112","choiceValue": "very good"},
{"choiceID": "12311113113","choiceValue": "bad",}
],
}]
},
{"categoryID": "12311","categoryName": "External",
"question": [
{"questionID": "12311111","questionName": "tell me snything",},
{"questionID": "123ques","questionName": "ashjsh",},
{"questionID": "123test","questionName": null,}
]},
{"categoryID": "141414141","categoryName": "",}]
},
{"categoryGroupID": "1232","categoryGroupName": "Communication",
"category": [
{"categoryID": "12321","categoryName": "Style"}]
},
{"categoryGroupID": "1233","categoryGroupName": "Overall Satisfaction",
"category": [
{"categoryID": "123222","categoryName": "",},
{"categoryID": "12331","categoryName": "Customer Satisfaction",}]
},
{"categoryGroupID": "12331","categoryGroupName": null}
]