Creating a JSON object with the following structure is something I'm trying to accomplish:
{
"PROMO": {
"ID": 1,
"NAME": "PROMO ONE",
"BUNDLES": {
"0": {
"BUNDLE": {
"BUNDLE_ID": 1,
"BUNDLE_NAME": "BUNDLE ONE"
},
"ARTICLE": {
"ARTICLE_IDS": "550,398,475"
}
},
"1": {
"BUNDLE": {
"BUNDLE_ID": 1,
"BUNDLE_NAME": "BUNDLE ONE"
},
"ARTICLE": {
"ARTICLE_IDS": "125,250,323"
}
}
}
}
}
My goal is to merge the BUNDLE
and ARTICLE
objects and then add them to the BUNDLES
array. I have been unsuccessful in my attempts to combine the two objects.
I have attempted the following approach:
var BUNDLES = [];
var BUNDLE = {};
var ARTICLE = {};
BUNDLE.BUNDLE_ID = 1;
BUNDLE.BUNDLE_NAME = "BUNDLE ONE";
ARTICLE.ARTICLE_IDS = "550,398,475";
// Here, I aim to merge ARTICLE and BUNDLE before pushing into the array
BUNDLES.push(BUNDLE)