Dynamically build JSON object list from Javascript
This question already has an answer here:
创建替换属性数组并在其中推入对象:
var o = {};
o.Name. = $("#Name").val();
o.Phone = $("#Phone").val();
o.Replacements = [];
o.Replacements.push({
Company: $("#Company1").val(),
Amount: $("#Amount1").val()
}, {
Company: $("#Company2").val(),
Amount: $("#Amount2").val()
});
$("#txtJSON").val(JSON.stringify(o));
链接地址: http://www.djcxy.com/p/46334.html
上一篇: 将文本字段更新为JSON字符串