How to create json like a tree structure using id and parentid from other json object
<p>I have a json like:</p>

<pre><code>[{
            "id": 11865,
            "parentid": null,
            "levelid": 63,
            "name": "Total"
        },
        {
            "id": 10143,
            "parentid": 11865,
            "levelid": 19,
            "name": "Productive"
        },
        {
            "id": 11873,
            "parentid": 10143,
            "levelid": 20,
            "name": "Regular"
        },
        {
            "id": -852,
            "parentid": 11873,
            "levelid": 255,
            "name": "801-REGULAR"
        },
        {
            "id": -888,
            "parentid": 11873,
            "levelid": 255,
            "name": "888-Regular 2"
        }]
</code></pre>

<p>And I need to change it some thing like that</p>

<pre><code>[{
  "id":11865,
  "levelid":63,
  "parentid": null,
  "name": "Total",
  "children":[{ 
                "id":10143, 
                "parentid":11865, 
                "level":19, 
                "name": "Productive"
                "children":[{
                              "id": 10144,
                              "parentid":10143,
                              "levelid":20,
                              "name": "Other",
                              "children":[{......}]
             }];
</code></pre>

<p>This new json is based on parent child relation. Also I am implementing this on sever side in node js. Can Any one help on this ?</p>