Access object nested under an object with a variable name

I am trying to access some strings of a nested object.This object has a parent object with a variable name (Unix timestamp). The object I want to access is shown below as acmecorp and that value does not change
Here’s a small example response that I get:

[
  {
    "1679270400": {
      "type": "cd",
      "acmecorp": {
        "onnetCalls": "0",
        "offnetCalls": "0",
        "totalDurationOnnet": "0",
        "totalDurationOffnet": "0",
        "date": "Mon, 20 Mar 2023 00:00:00 +0000"
      }
    },
    "1679356800": {
      "type": "cd",
      "acmecorp": {
        "onnetCalls": "0",
        "offnetCalls": "1",
        "totalDurationOnnet": "0",
        "totalDurationOffnet": "11",
        "date": "Tue, 21 Mar 2023 00:00:00 +0000"
      }
    },
    "1679443200": {
      "type": "cd",
      "acmecorp": {
        "onnetCalls": "0",
        "offnetCalls": "3",
        "totalDurationOnnet": "0",
        "totalDurationOffnet": "179",
        "date": "Wed, 22 Mar 2023 00:00:00 +0000"
      }
    }
  }
]

Keep in mind that this is typically a response with several hundred objects, so manually accessing the strings under acmecorp isn’t really feasible.

Any help on this would be greatly appreciated, I’ve stumped myself on this. Thanks in advance!

I’ve included a sample workflow that does this below. The main part is this:

let keys = Object.keys(data); // Extract a list of all the Unix timestamps
let out = keys.map(x => data[x].acmecorp) // Get the 'acmecorp' object for each one

Full workflow:

1 Like

That did the trick! Thank you so much!!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.