title: How to Convert nested json to array of object in Javascript?
body: <p>I've a deep nested object like this:</p>
  
  <pre><code>{
    'name_1': 'val',
    'name_2': 'val',
    'name_3': {
      'name_4': {
        'name_5': {
          'name_6': 'val',
          'name_7': 'val',
          'name_8': {
            'name_9': 'val'
          }
        }
      }
    }
  }
  </code></pre>
  
  <blockquote>
    <p>Here key can be anything instead of name_1, name_2, name_3...etc(names key
    as name_1, name_2.. just for quick understanding)</p>
  </blockquote>
  
  <p><strong>I wanted to convert the above json to array of objects in the below mentioned format</strong></p>
  
  <pre><code>[
    { "id": "1", "name": 'name_1: val', "parent_id": "0"},
    { "id": "2", "name": 'name_2: val', "parent_id": "0"},
    { "id": "3", "name": 'name_3', "parent_id": "0"},
    { "id": "4", "name": 'name_4', "parent_id": "3"},
    { "id": "5", "name": 'name_5', "parent_id": "4"},
    { "id": "6", "name": 'name_6: val', "parent_id": "5"},
    { "id": "7", "name": 'name_7: val', "parent_id": "5"},
    { "id": "8", "name": 'name_8', "parent_id": "5"},
    { "id": "9", "name": 'name_9: val', "parent_id": "8"},
  ]
  </code></pre>
  
  <p><em>Any help would be really apprectiated!!</em></p>