How to integrate an dynamically generated JSON Object into an other object?
- by Marco Ciarfaglia
How can I put this JSON Object in the function or object below?
// this function generates an JSON Object dynamically
$(".n_ListTitle").each(function(i, v) {
var node = $(this);
var nodeParent = node.parent();
var nodeText = node.text();
var nodePrice = node.siblings('.n_ListPrice');
var prodPrice = $(nodePrice).text();
var prodId = nodeParent.attr('id').replace('ric', '');
var prodTitle = nodeText;
var json = {
id : prodId,
price : prodPrice,
currency : "CHF",
name : prodTitle
};
return json;
});
TDConf.Config = {
products : [
// here should be inserted the JSON Object
{id: "[product-id1]", price:"[price1]", currency:"[currency1]", name:"[product-name1]"},
{id: "[product-id2]", price:"[price2]", currency:"[currency2]", name:"[product-name2]"},
...
})],
containerTagId :"..."
};
If it is not understandable please ask :)
Thanks in advance for helping me to figure out!