再会,
我有这个 JSON 对象,我想将这两个值推送到另一个数组中
var line4 = [
{"viewed":2, "sumDate":1377129600000, "redeemed" : 8},
{"viewed":12, "sumDate":1377129600000, "redeemed" : 3},
{"viewed":18, "sumDate":1377129600000, "redeemed" : 13}
];
我希望新的 line4 像这种格式
newline4 = [["2008-06-30", 2], ["2008-7-14", 12, ["2008-7-28", 18]]
我似乎无法将其正确格式化为我的数组
$(line4).each(function (index, value) {
console.log("value: " + value);
$(value).map(function(){
d = new Date(parseInt(this.sumDate));
this.sumDate = (1 + d.getMonth()) + '/'+ d.getDate() + '/' + d.getFullYear().toString().slice(-2);
console.log("sumdate : " +this.sumDate);
console.log("viewed : " +this.viewed);
newline4.push([this.sumDate, this.viewed]);
});
});
但我得到
newline4 : 8/21/13,2,8/21/13,12,8/21/13,18