处理Google组织结构图的JSON数据

时间:2015-01-15 03:01:54

标签: javascript json orgchart

我有一个看起来像这样的JSON数据

{  
    "name": "k11",
    "id": "GOLD1501131955983380",
    "data": {
        "rank": "Agent",
        "email": "k11@gmail.com",
        "registrationDate": "13 Jan 2015 11:55:15 GMT",
        "contact": "123123"
    },
    "children": [{
        "name": "k11a",
        "id": "GOLD1501131956858350",
        "data": {
            "registrationDate": "Jan 13, 2015 7:56:15 PM",
            "rank": "Agent",
            "email": "k11a@gmail.com",
            "contact": "123123213123"
        },
        "children": [{
            "name": "k11a2",
            "id": "GOLD1501131959324173",
            "data": {
                "registrationDate": "Jan 13, 2015 7:59:25 PM",
                "rank": "Agent",
                "email": "k11a2@gmail.com",
                "contact": "123123123"
            },
            "children": []
        }, {
            "name": "k11a1",
            "id": "GOLD1501131958998436",
            "data": {
                "registrationDate": "Jan 13, 2015 7:58:27 PM",
                "rank": "Agent",
                "email": "k11a1@gmail.com",
                "contact": "123123123"
            },
            "children": []
        }]
    }]
  }
}

我需要的是处理这些数据以与google org图表兼容,这应该是这样的

{
    "cols": [{
        "id": "GOLD1501131955983380",
        "name": "k11",
        "data": {
              "registrationDate": "Jan 13, 2015 7:59:25 PM",
               "rank": "Agent",
               "email": "k11a2@gmail.com",
               "contact": "123123123"
       }
    }, {
    }]
    "rows": [{
        "c": [{
            "v": "k11"
        }]
    }, {
        "c": [{
            "v": "k11a2"
        }, {
            "v": "k11a"
        }]
    }]
} 

有点像谷歌排行榜的结构化要求。

请帮助我

0 个答案:

没有答案