0

I have the following let data which outputs the following JSON:

{
  "OP_LC_check": [
    0
  ],
  "OP_LG_check": [
    0
  ],
  "LY_LC_check": [
    5374
  ],
  "LY_GC_check": [
    6086
  ],
  "ACT_LC_check": [
    5299
  ],
  "ACT_GC_check": [
    3241
  ],
  "ACT_GC_AT_OP_check": [
    2980
  ],
  "ACT_GC_AT_LY_check": [
    3093
  ]
}

I want to add the values of each item to an array (dynamically) to get this output: [0, 0, 5374 ,6086, 5299,...]

Thank you

I have tried multiple things but can´t figure it out

  • Does this answer your question? [How to convert JSON to Array in Javascript](https://stackoverflow.com/questions/45930723/how-to-convert-json-to-array-in-javascript) – mgm793 Jan 17 '23 at 12:33
  • 1
    `Object.values(yourObject).flat()`. If guaranteed order is important: `[ "OP_LC_check", "OP_LG_check", "LY_LC_check", "LY_GC_check", "ACT_LC_check", "ACT_GC_check", "ACT_GC_AT_OP_check", "ACT_GC_AT_LY_check" ].map((key) => yourObject[key][0])`. – Sebastian Simon Jan 17 '23 at 12:36

0 Answers0