title: Generate (multilevel) flare.json data format from flat json
body: <p>I have a flat json file structure like:</p>
  
  <pre><code>[
   { "name" : "ABC", "parent":"DEF", "relation": "ghi", "depth": 1 },
   { "name" : "DEF", "parent":"null", "relation": "null", "depth": 0 },
   { "name" : "new_name", "parent":"ABC", "relation": "rel", "depth": 2 }
   ....
   ....
   ]
  </code></pre>
  
  <p>And what I want is a nested file structure like:</p>
  
  <pre><code>[ 
   {
     "name": "DEF",
     "parent": "null",
     "relation": "null",
     "children": [
                   { "name": "ABC",
                     "parent": "DEF",
                     "relation": "ghi",
                     "children": [
                                   "name": "new_name",
                                   ...
                                   "children": []
                                 ]
                   }
                 ]
    }
   ]
  </code></pre>
  
  <p>There is no limit on how many levels deep it should go. The current max I have is 30.
  There is no limit on the number of children a node can have. Eg. The root node has all the remaining as its children.</p>
  
  <p>What I have tried till now? </p>
  
  <ul>
  <li><p>Read about d3.nest() and how it is able to nest but not perfectly. 
  <a href="https://groups.google.com/forum/?fromgroups=#!topic/d3-js/L3UeeUnNHO8/discussion">https://groups.google.com/forum/?fromgroups=#!topic/d3-js/L3UeeUnNHO8/discussion</a></p></li>
  <li><p>Wrote a python script for this, but it gets stuck with the null values and also since the data is not bounded (It increases everyday in double figures) so it is very very slow.</p></li>
  <li><p>I tried the force directed layout and it worked very well but I want to add another layout that makes the visualization easy. </p></li>
  <li><p>I could go with some other python scripts posted but they do not seem to carry forward any other information than "name" and "children".</p></li>
  <li><p>I read this: <a href="http://blog.pixelingene.com/2011/07/building-a-tree-diagram-in-d3-js/">http://blog.pixelingene.com/2011/07/building-a-tree-diagram-in-d3-js/</a>
  but they too have the right format data in the first place. What I intend to create is <a href="http://bl.ocks.org/mbostock/4339083">http://bl.ocks.org/mbostock/4339083</a>. </p></li>
  </ul>
  
  <p>The source of the data is MS SQL Server database which I am fetching and parsing through python. Kindly help! i have been stuck at this for the past 2 weeks.</p>
  
  <p>Thanks</p>