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

2
  • Does this answer your question? How to convert JSON to Array in Javascript Commented Jan 17, 2023 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]). Commented Jan 17, 2023 at 12:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.