87,969
社区成员
发帖
与我相关
我的任务
分享
{
"零售单":[
{"vip":"**","金额":"**","优惠":"**"……}
],
"零售商品":[
{"商品一":"**","折扣":"**","数量":"**",……},
{"商品二":"**","折扣":"**","数量":"**",……},
……
],
"经手人":[
{"经手人一":"**","比例":"**",……},
{"经手人一":"**","比例":"**",……},
……
]
}
var arr1 = new Object();
arr1.one = 1;
arr1.two = 2;
var arr2 = new Object();
arr2.three = 3;
arr2.four = 4;
var arr3 = new Object();
arr3.five = 5;
arr3.six = 6;
var arr4 = new Object();
arr4.seven = 7;
arr4.eight = 8;
var arr5 = new Array();
arr5.push(arr3);
arr5.push(arr4);
var obj = new Object();
obj.yi = arr1;
obj.er = arr2;
obj.san = arr5;
alert(JSON.stringify(obj));
弹出:{
"yi": {
"one": 1,
"two": 2
},
"er": {
"three": 3,
"four": 4
},
"san": [{
"five": 5,
"six": 6
}, {
"seven": 7,
"eight": 8
}]
}
正是我需要的效果。当然弹出来不是这样的,为了便于显示,才格式化的var arr1 = [
{"vip":"**","金额":"**","优惠":"**"……}
];
var arr2 = [
{"商品一":"**","折扣":"**","数量":"**",……},
{"商品二":"**","折扣":"**","数量":"**",……},
……
];
var obj = {
"零售单": arr1,
"零售商品": arr2
}