0

I am new to javascript and I am having a difficulty in looping through a set of objects and arrays to find the right value that matches. Please refer the example below.

[
    {
        "C02G6A8HLJE": [
            {
                "reply_users": [ ],
                "reply_users_count": 0,
                "reply_count": 0,
                "ts": "1652781270.572469",
                "channel_name": "n8n-stage-test",
                "team_id": "T032648LE",
                "share_user_id": "U02BUBQ4C2H"
            }
        ]
    }
]

In the above set block the "C02G6A8HLJE" is not a constant value, meaning, every-time this values changes. Now what I want to do is to get the "ts" value inside this block. How can I achieve that. I tired for.each and other map functions which but I am ending up in errors.

T.J. Crowder
  • 959,406
  • 173
  • 1,780
  • 1,769
  • 1
    Is the (outer) object always at index 0? Does it always have just one property (even though the property name changes)? What did your attempts look like (even if they didn't work, we can help you understand why). – T.J. Crowder May 17 '22 at 10:40
  • Related: https://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json – T.J. Crowder May 17 '22 at 10:40
  • `const ts = JSON.stringify(obj).match(/"ts":"(.*?)"/)[1]` if you can use that – mplungjan May 17 '22 at 11:07

0 Answers0