js集合数据分组组合

现有数据格式

[{"id":"5ce5320ec2b2693d249e272c","province":"山东","schools":["山东师范大学","青岛科技大学","山东建筑大学","青岛大学","济南大学","山东大学","中国石油大学(华东)","山东财经大学","山东农业大学","哈尔滨工业大学(威海)","中国海洋大学"]},{"id":"5ce5320ec2b2693d249e272d","province":"上海","schools":["东华大学","复旦大学","华东师范大学","同济大学","上海交通大学","华东理工大学"]},{"id":"5ce5320ec2b2693d249e272e","province":"吉林","schools":["吉林财经大学","长春工业大学","长春大学","吉林大学","东北师范大学"]},{"id":"5ce5320ec2b2693d249e272f","province":"福建","schools":["集美大学","华侨大学","厦门大学","福州大学"]},{"id":"5ce5320ec2b2693d249e2730","province":"甘肃","schools":["兰州交通大学","兰州大学"]},{"id":"5ce5320ec2b2693d249e2731","province":"山西","schools":["山西大学","太原理工大学","山西财经大学"]},{"id":"5ce5320ec2b2693d249e2732","province":"四川","schools":["成都中医药大学","西南民族大学","四川师范大学","西华大学","电子科技大学","成都学院","四川农业大学","西南交通大学","四川大学","西南石油大学","成都理工大学"]},{"id":"5ce5320ec2b2693d249e2733","province":"河南","schools":["河南大学","中原工学院","华北水利水电大学","河南理工大学","河南师范大学","郑州大学","郑州轻工业学院"]},{"id":"5ce5320ec2b2693d249e2734","province":"河北","schools":["河北大学","河北科技大学"]},{"id":"5ce5320ec2b2693d249e2735","province":"浙江","schools":["浙江财经大学","宁波大学","浙江工商大学","温州大学","中国计量学院","杭州师范大学","杭州电子科技大学","浙江大学","浙江师范大学","浙江工业大学","浙江理工大学"]},{"id":"5ce5320ec2b2693d249e2736","province":"重庆","schools":["四川外国语大学","重庆邮电大学","重庆师范大学","重庆大学","重庆工商大学","重庆理工大学","重庆交通大学","重庆科技学院","西南大学"]},{"id":"5ce5320ec2b2693d249e2737","province":"广西","schools":["广西民族大学","广西大学","广西师范大学","桂林电子科技大学","桂林理工大学"]},{"id":"5ce5320ec2b2693d249e2738","province":"湖北","schools":["江汉大学","三峡大学","武汉理工大学","华中农业大学","华中师范大学","中南民族大学","武汉工程大学","长江大学","宣讲时间:","中南财经政法大学","武汉纺织大学","中国地质大学","武汉大学","华中科技大学","湖北经济学院"]},{"id":"5ce5320ec2b2693d249e2739","province":"湖南","schools":["湘潭大学","湖南大学","湖南工业大学","湖南商学院","湖南科技大学","南华大学","长沙理工大学","湖南师范大学","湖南农业大学","中南大学"]},{"id":"5ce5320ec2b2693d249e273a","province":"江西","schools":["江西科技师范大学","江西财经大学","华东交通大学","南昌航空大学","江西师范大学","南昌大学","江西农业大学"]},{"id":"5ce5320ec2b2693d249e273b","province":"云南","schools":["云南师范大学","昆明理工大学","云南民族大学"]},{"id":"5ce5320ec2b2693d249e273c","province":"黑龙江","schools":["哈尔滨商业大学","哈尔滨理工大学","东北林业大学","哈尔滨师范大学","哈尔滨工业大学","黑龙江大学","东北农业大学","黑龙江科技大学"]},{"id":"5ce5320ec2b2693d249e273d","province":"辽宁","schools":["沈阳理工大学","沈阳农业大学","东北财经大学","东北大学","大连大学","大连理工大学","沈阳化工大学","辽宁工程技术大学","辽宁大学"]},{"id":"5ce5320ec2b2693d249e273e","province":"广东","schools":["汕头大学","华南理工大学","广东财经大学","华南农业大学","广州大学","暨南大学","广东工业大学","广东外语外贸大学","华南师范大学"]},{"id":"5ce5320ec2b2693d249e273f","province":"天津","schools":["南开大学","河北工业大学","天津财经大学"]},{"id":"5ce5320ec2b2693d249e2740","province":"陕西","schools":["西北大学 ","西北政法大学","西安外国语大学","长安大学","陕西科技大学","西安电子科技大学","陕西师范大学","西安建筑科技大学","西安财经学院","西安工业大学","西安交通大学","西北大学","西北工业大学","西安邮电大学","西北农林科技大学"]},{"id":"5ce5320ec2b2693d249e2741","province":"江苏","schools":["南京师范大学","中国药科大学","扬州大学","江苏大学","南京大学","南京工程学院","南京邮电大学","南京审计大学","苏州大学","南京农业大学","河海大学","东南大学","南京理工大学","南京信息工程大学","江南大学","南京航空航天大学","南京工业大学","中国矿业大学"]},{"id":"5ce5320ec2b2693d249e2742","province":"北京","schools":["北京科技大学","对外经济贸易大学","中国地质大学(北京)","北京理工大学","北京交通大学","中国石油大学(北京)","北京大学","中国政法大学","北京化工大学","清华大学","北京航空航天大学","中国人民大学","中国矿业大学(北京)","中央民族大学"]},{"id":"5ce5320ec2b2693d249e2743","province":"安徽","schools":["安徽工业大学","安徽大学","合肥工业大学","安徽建筑大学","安徽财经大学","安徽师范大学"]}]

我需要让数据四个一分组变成一个对象

 var that = this;
 let result = []

 for (var i = 0, len = res.length; i < len; i += 4) {
        result.push(res.slice(i, i + 4));
      }

转换后的数据格式

[[{"id":"5ce5320ec2b2693d249e272c","province":"山东","schools":["山东师范大学","青岛科技大学","山东建筑大学","青岛大学","济南大学","山东大学","中国石油大学(华东)","山东财经大学","山东农业大学","哈尔滨工业大学(威海)","中国海洋大学"]},{"id":"5ce5320ec2b2693d249e272d","province":"上海","schools":["东华大学","复旦大学","华东师范大学","同济大学","上海交通大学","华东理工大学"]},{"id":"5ce5320ec2b2693d249e272e","province":"吉林","schools":["吉林财经大学","长春工业大学","长春大学","吉林大学","东北师范大学"]},{"id":"5ce5320ec2b2693d249e272f","province":"福建","schools":["集美大学","华侨大学","厦门大学","福州大学"]}],[{"id":"5ce5320ec2b2693d249e2730","province":"甘肃","schools":["兰州交通大学","兰州大学"]},{"id":"5ce5320ec2b2693d249e2731","province":"山西","schools":["山西大学","太原理工大学","山西财经大学"]},{"id":"5ce5320ec2b2693d249e2732","province":"四川","schools":["成都中医药大学","西南民族大学","四川师范大学","西华大学","电子科技大学","成都学院","四川农业大学","西南交通大学","四川大学","西南石油大学","成都理工大学"]},{"id":"5ce5320ec2b2693d249e2733","province":"河南","schools":["河南大学","中原工学院","华北水利水电大学","河南理工大学","河南师范大学","郑州大学","郑州轻工业学院"]}],[{"id":"5ce5320ec2b2693d249e2734","province":"河北","schools":["河北大学","河北科技大学"]},{"id":"5ce5320ec2b2693d249e2735","province":"浙江","schools":["浙江财经大学","宁波大学","浙江工商大学","温州大学","中国计量学院","杭州师范大学","杭州电子科技大学","浙江大学","浙江师范大学","浙江工业大学","浙江理工大学"]},{"id":"5ce5320ec2b2693d249e2736","province":"重庆","schools":["四川外国语大学","重庆邮电大学","重庆师范大学","重庆大学","重庆工商大学","重庆理工大学","重庆交通大学","重庆科技学院","西南大学"]},{"id":"5ce5320ec2b2693d249e2737","province":"广西","schools":["广西民族大学","广西大学","广西师范大学","桂林电子科技大学","桂林理工大学"]}],[{"id":"5ce5320ec2b2693d249e2738","province":"湖北","schools":["江汉大学","三峡大学","武汉理工大学","华中农业大学","华中师范大学","中南民族大学","武汉工程大学","长江大学","宣讲时间:","中南财经政法大学","武汉纺织大学","中国地质大学","武汉大学","华中科技大学","湖北经济学院"]},{"id":"5ce5320ec2b2693d249e2739","province":"湖南","schools":["湘潭大学","湖南大学","湖南工业大学","湖南商学院","湖南科技大学","南华大学","长沙理工大学","湖南师范大学","湖南农业大学","中南大学"]},{"id":"5ce5320ec2b2693d249e273a","province":"江西","schools":["江西科技师范大学","江西财经大学","华东交通大学","南昌航空大学","江西师范大学","南昌大学","江西农业大学"]},{"id":"5ce5320ec2b2693d249e273b","province":"云南","schools":["云南师范大学","昆明理工大学","云南民族大学"]}],[{"id":"5ce5320ec2b2693d249e273c","province":"黑龙江","schools":["哈尔滨商业大学","哈尔滨理工大学","东北林业大学","哈尔滨师范大学","哈尔滨工业大学","黑龙江大学","东北农业大学","黑龙江科技大学"]},{"id":"5ce5320ec2b2693d249e273d","province":"辽宁","schools":["沈阳理工大学","沈阳农业大学","东北财经大学","东北大学","大连大学","大连理工大学","沈阳化工大学","辽宁工程技术大学","辽宁大学"]},{"id":"5ce5320ec2b2693d249e273e","province":"广东","schools":["汕头大学","华南理工大学","广东财经大学","华南农业大学","广州大学","暨南大学","广东工业大学","广东外语外贸大学","华南师范大学"]},{"id":"5ce5320ec2b2693d249e273f","province":"天津","schools":["南开大学","河北工业大学","天津财经大学"]}],[{"id":"5ce5320ec2b2693d249e2740","province":"陕西","schools":["西北大学 ","西北政法大学","西安外国语大学","长安大学","陕西科技大学","西安电子科技大学","陕西师范大学","西安建筑科技大学","西安财经学院","西安工业大学","西安交通大学","西北大学","西北工业大学","西安邮电大学","西北农林科技大学"]},{"id":"5ce5320ec2b2693d249e2741","province":"江苏","schools":["南京师范大学","中国药科大学","扬州大学","江苏大学","南京大学","南京工程学院","南京邮电大学","南京审计大学","苏州大学","南京农业大学","河海大学","东南大学","南京理工大学","南京信息工程大学","江南大学","南京航空航天大学","南京工业大学","中国矿业大学"]},{"id":"5ce5320ec2b2693d249e2742","province":"北京","schools":["北京科技大学","对外经济贸易大学","中国地质大学(北京)","北京理工大学","北京交通大学","中国石油大学(北京)","北京大学","中国政法大学","北京化工大学","清华大学","北京航空航天大学","中国人民大学","中国矿业大学(北京)","中央民族大学"]},{"id":"5ce5320ec2b2693d249e2743","province":"安徽","schools":["安徽工业大学","安徽大学","合肥工业大学","安徽建筑大学","安徽财经大学","安徽师范大学"]}]]

 

你可能感兴趣的:(微信小程序开发)