title: How to create array for Angular tree from JSON
body: <p>I'm new to Angular. I need to design an Angular tree from JSON file received from database. I'm able to create Angular tree using static data, but I'm not able to create an array for tree from JSON retrieved from database.</p>
  <p><strong>Sample Json:</strong></p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;success&quot;: 1,
      &quot;data&quot;: [
          {
              &quot;clustername&quot;: &quot;c2&quot;,
              &quot;monthday&quot;: &quot;12/29&quot;
          },
          {
              &quot;clustername&quot;: &quot;C3&quot;,
              &quot;monthday&quot;: &quot;12/29&quot;
          },
          {
              &quot;clustername&quot;: &quot;C71&quot;,
              &quot;monthday&quot;: &quot;12/31&quot;
          },
          {
              &quot;clustername&quot;: &quot;C34&quot;,
              &quot;monthday&quot;: &quot;12/31&quot;
          },
          {
              &quot;clustername&quot;: &quot;C998&quot;,
              &quot;monthday&quot;: &quot;1/4&quot;
          },
          {
              &quot;clustername&quot;: &quot;C99&quot;,
              &quot;monthday&quot;: &quot;1/4&quot;
          }
      ]
  }
  </code></pre>
  <p><strong>Component.ts Service that returns data :</strong></p>
  <pre><code>this.db.fetchPlannedReleaseDate().subscribe(data =&gt; {
      console.log(data) // able to see above json file
  });
  </code></pre>
  <p>I need help to write logic to create below array from JSON (mentioned above):</p>
  <pre><code>const TREE_DATA: Version[] = [
    {
      name: 12/29,
      children: [{name: c2}, {name: C3}],
    },
    {
      name: 12/31,
      children: [{name: C71}, {name: C34}],
    },
    {
      name: 1/4,
      children: [{name: C998}, {name: C99},
    }
  ];
  </code></pre>