如何将此 JSON 对象放入下面的函数或对象中?
// 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",
mame : 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 :"..."
};
如果无法理解,请询问:) 提前感谢您帮助我弄清楚!