如何将此平面json数据转换为D3分层json数据?

时间:2015-07-04 11:53:02

标签: javascript json d3.js

我有这个数据

    {
    "vision": [
        "ForwhoisathatunlikeourproductCarPooling",
        "ForwhoisathatunlikeourproductCarPooling"
    ],
    "actors": [
        "sddbbfcjwdfcc",
        "kjbkjjkbkjb"
    ]
}

我要将其转换为可与d3.js一起使用的分层数据。

这是我试图适应我的数据的地方。 http://bl.ocks.org/mbostock/2966094。 json数据的预期结构类似于

    {
  "name": "Clifford Shanks",
  "born": 1862,
  "died": 1906,
  "location": "Petersburg, VA",
  "parents": [
    {
      "name": "James Shanks",
      "born": 1831,
      "died": 1884,
      "location": "Petersburg, VA",
      "parents": [
        {
          "name": "Robert Shanks",
          "born": 1781,
          "died": 1871,
          "location": "Ireland/Petersburg, VA"
        },
        {
          "name": "Elizabeth Shanks",
          "born": 1795,
          "died": 1871,
          "location": "Ireland/Petersburg, VA"
        }
      ]
    },
    {
      "name": "Ann Emily Brown",
      "born": 1826,
      "died": 1866,
      "location": "Brunswick/Petersburg, VA",
      "parents": [
        {
          "name": "Henry Brown",
          "born": 1792,
          "died": 1845,
          "location": "Montgomery, NC"
        },
        {
          "name": "Sarah Houchins",
          "born": 1793,
          "died": 1882,
          "location": "Montgomery, NC"
        }
      ]
    }
  ]
}

0 个答案:

没有答案