首页 > 应用开发 > > JS ES6拼接字符串
var oJSON = [
{businessNum:2,merchantBusinessId:456},
{businessNum:1,merchantBusinessId:154},
{businessNum:3,merchantBusinessId:336},
{businessNum:5,merchantBusinessId:108}
];制一个函数 fn(json); 出来如一下这种形式(字符串):
"[{\"amount\":\"1\",\"merbusinessId\":\"92\"},{\"amount\":\"1\",\"merbusinessId\":\"94\"},{\"amount\":\"1\",\"merbusinessId\":\"107\"}]"原属数据:
oJSON = [{
brandName: "",
businessCode: "0b489a6d-9844-4f0e-a977-d5bb983d36e5",
businessName: "内饰清洁",
businessNum: 2,
id: null,
merchantBusinessId: 95,
merchantId: 34,
price: 300,
privilegePrice: 0,
shoppingCarDetialsId: 659,
totalCurrentPrice: null,
totalNum: null,
totalPrice: null,
userId: 439,
}, {
brandName: "",
businessCode: "0b489a6d-9844-4f0e-a977-d5bb983d36e5",
businessName: "内饰清洁",
businessNum: 1,
id: null,
merchantBusinessId: 108,
merchantId: 34,
price: 300,
privilegePrice: 0,
shoppingCarDetialsId: 659,
totalCurrentPrice: null,
totalNum: null,
totalPrice: null,
userId: 439,
}, {
brandName: "",
businessCode: "0b489a6d-9844-4f0e-a977-d5bb983d36e5",
businessName: "内饰清洁",
businessNum: 5,
id: null,
merchantBusinessId: 666,
merchantId: 34,
price: 300,
privilegePrice: 0,
shoppingCarDetialsId: 659,
totalCurrentPrice: null,
totalNum: null,
totalPrice: null,
userId: 439,
}]; //取 businessNum 和 merchantBusinessId 字段来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2310/viewspace-3129868/ ,如需转载,请注明出处,否则将追究法律责任。