//例如,后台返回的数据为: var json = { data: [ {value: 103.95, name: "法拉利"}, {value: 103.2, name: "北汽幻速"}, {value: 97.44, name: "WEY"}, {value: 89.46, name: "北汽绅宝"}, {value: 88.87, name: "比速汽车"}, {value: 88.05, name: "汉腾汽车"}, {value: 85.96, name: "五十铃"} ] }; //但是前台需要的数据格式为: var newData = [ {name: "法拉利", data: [103.95], type: "bar"}, {name: "北汽幻速", data: [103.2], type: "bar"}, {name: "WEY", data: [97.44], type: "bar"}, {name: "北汽绅宝", data: [89.46], type: "bar"}, {name: "比速汽车", data: [88.87], type: "bar"}, {name: "汉腾汽车", data: [88.05], type: "bar"}, {name: "五十铃", data: [85.96], type: "bar"} ]; //实现的方法为: //第一步:声明三个空数组,分别保存 value、nam、保存新对象的值; var val = []; var nam = []; var newData = []; for(var i = 0; i < json.data.length; i++){ val.push(json.data[i].value); nam.push(json.data[i].name); var obj = { name: json.data[i].name, data: [json.data[i].value], type: ‘bar‘ }; newData.push(obj); } console.log(‘newData‘, newData); //目前这个newData就是所需要的新数据。