title: How to convert my data into a format suitable for d3.js sunburst?
body: <p>I have a data like this: <a href="https://jsfiddle.net/L79wjn0x/" rel="nofollow noreferrer">https://jsfiddle.net/L79wjn0x/</a>, and I would like to convert it in this format <a href="https://jsfiddle.net/49n1jmL5/" rel="nofollow noreferrer">https://jsfiddle.net/49n1jmL5/</a>. I am trying to make use of <code>d3.nest</code> method to change the format but unable to make it work. In my data children are linked with parent through parents'id.</p>
  
  <p>Sample data I have is like below. Children are linked with parent 
  through parent's id that is children's <code>parent_id</code> key is same that of 
  parent's id key. </p>
  
  <pre><code> [{
      "id": 1,
      "name": "ab",
      "parent_id": null,
      "value": 120,
      "tree_level": 1
    },
    {
      "id": 2,
      "name": "ac",
      "parent_id": null,
      "value": 110,
      "tree_level": 1
    } {
      "id": 3,
      "name": "abc",
      "parent_id": 1,
      "value": 30,
      "tree_level": 2
    },
    {
      "id": 4,
      "name": "abcd",
      "parent_id": 1,
      "value": 90,
      "tree_level": 2
    },
    {
      "id": 5,
      "name": "abc",
      "parent_id": 3,
      "value": 10,
      "tree_level": 3
    },
    {
      "id": 6,
      "name": "abc",
      "parent_id": 3,
      "value": 20,
      "tree_level": 3
    }
  ]
  </code></pre>
  
  <p>and i would like the above json format to be converted like below format. 
  Can anyone lead me to the correct way</p>
  
  <pre><code>{
    "id": 1,
    "name": "ab",
    "parent_id": null,
    "value": 120,
    "tree_level": 1,
    children: [{
        "id": 3,
        "name": "abc",
        "parent_id": 1,
        "value": 30,
        "tree_level": 2
        children: [{
            "id": 5,
            "name": "abc",
            "parent_id": 3,
            "value": 10,
            "tree_level": 3
          },
          {
            "id": 6,
            "name": "abc",
            "parent_id": 3,
            "value": 20,
            "tree_level": 3
          }
        ]
      },
      {
        "id": 4,
        "name": "abcd",
        "parent_id": 1,
        "value": 90,
        "tree_level": 2,
        children: []
      }
    ]
  }, {
    "id": 2,
    "name": "ac",
    "parent_id": null,
    "value": 110,
    "tree_level": 1,
    children: []
  }
  </code></pre>
  
  <p>Below is the code which I wrote to convert but it doesn't work for me. 
  It is not creating children inside, instead creating it outside. </p>
  
  <pre><code>var nested = d3.nest()
    .key(function(d) {
      if (d.parent_id === null)
        return d;
    }).rollup(function(ele) {
      return ele.map(function(c) {
        return {
          "id": c.id,
          "parent_id": c.parent_id,
          "name": c.name,
          "logValue": c.logValue,
          "tree_level": c.tree_level
        };
      });
    }).entries(this.dataset);
  console.log(nested)
  </code></pre>
  
  <p>will d3.nest() work or i need something else ? </p>