zoukankan      html  css  js  c++  java
  • json结构更改的方法 把date有数据的分类

      data=[
            {
                "content": "如何走进智障儿童的内心",
                "title": "如何走进智障儿童的内心",
                "second": 27,
                "name": "基础课程",
                "categoryId": 12,
                "courseId": 292,
                "noteId": 143,
                "type": 1,
                "date": "11-23",
                "specialId": 186
            },
            {
                "content": "孩子的安全感,不仅仅是精神需求上,而且是物质上。所以要努力给孩子做一个好榜样。",
                "title": "如何构建孩子的安全感",
                "second": 0,
                "name": "基础课程",
                "categoryId": 5,
                "courseId": 818,
                "noteId": 130,
                "type": 1,
                "date": "11-21",
                "specialId": 172
            },
            {
                "content": "引导儿童学会感恩父母,诚实为人,诚信做事。",
                "title": "【专题总览】引导儿童学会感恩父母、诚实为人、诚信做事",
                "second": 0,
                "name": "基础课程",
                "categoryId": 5,
                "courseId": 817,
                "noteId": 129,
                "type": 1,
                "specialId": 172
            }
        ]
        console.log(data.length);
        var team_date = [];
         var indexs = -1;
        data.forEach(function(i,x){
            console.log(i.date);
            if(i.date){
                var team = {
                    aa: '',
                    list: []
                }
                indexs++;
                team.date=i.date;
                team.list.push(i);
                team_date.push(team);
            }else{
                team_date[indexs].list.push(i);
            }
        })
    

      http://jsrun.net/CGiKp/edit 在线案例

  • 相关阅读:
    leetcode1161
    leetcode1160
    校招真题练习034 倒水(贝壳)
    校招真题练习033 音乐列表(贝壳)
    校招真题练习032 连续相同字符串(头条)
    校招真题练习031 三支球队比分(头条)
    leetcode1144
    ArrayQueue(队列)
    LinkQueue(链队)
    快速幂
  • 原文地址:https://www.cnblogs.com/alone2015/p/7905375.html
Copyright © 2011-2022 走看看