How To Flatten Out The Array And Assign New Keys? (ts, Js)
From this long JSON file, I want to pick few keys and values. [{ c_id: '1', c: 'google', displayName: 'display name', myResults: [{ //type: Array type:
Solution 1:
const result = data.flatMap(({ c_id, c, index, myResults }) => ([
{ id: c_id, label: c, index },
...myResults.map(({ id, label }) => ({ id, label }))
]))
Maybe this would work, but I'm just guessing because your data seems inconsistent. c_id and id seem to get switched, google
is the "c" key but facebook
is the "connector key"
Post a Comment for "How To Flatten Out The Array And Assign New Keys? (ts, Js)"