Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Combine array of objects into one structured array

$
0
0

I got this array:

[
  { data: { '4321432': { foo: 'bar' } } },
  { data: { '4321432': { bar: 'foo' } } }
]

it's not always 4321432 could be several, for example

[
  { data: { '4321432': { foo: 'bar' } } },
  { data: { '4321432': { bar: 'foo' } } }
  { data: { '4321432': { yes: 'no' }, '5435': { example: true } } },
]

I want something like this in a end:

[
  {
    id: '4321432',
    foo: 'bar',
    bar: 'foo',
    yes: 'no'
  },
  {
    id: '5435',
    example: true
  }
]

Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>