title: Javascript building tree hierarchy
body: <pre><code>var array = [{"grandpa","father"}, {"father"}, {"grandpa","father","me"}];
  </code></pre>
  
  <p>Given the above array, I want to product a java-script object(JSON) like below, that has the parent-child like structure.</p>
  
  <pre><code>{"id":"grandpa",
   "children":[
      {"id":"father",
       "children":[
          {"id":"me",
           "children":[]
          }]
      }]
  }
  </code></pre>