How can I use a variable to locate an Object property for Update?

Options

I have an external API response which returns a list of codes.
{
"id": "401547429626",
"sequenceNumber": "62600",
"type": {
"id": "5",
"text": "xxx",
"abbreviation": "xxx"
},
{
"id": "401547429648",
"sequenceNumber": "64800",
"type": {
"id": "24",
"text": "Pass Reception",
"abbreviation": "REC"
}

I have an object which containing properties aligning to the returned Id's, i.e. 5, 24, etc.

"5": {
"homeTeam": {
"playTypeId": 5,
"playTypeDec": "Sacks",
"count": null
}

I am looping through the API response and need to update my object using the "id". How do I dynamically reference the object property (the existing variable)?

Apologies I am very new to the product. Much appreciated.

Best Answer

  • Max
    Max Member
    Answer ✓
    Options

    if you go with "for loop" with array as input, and did not edit default output, then inside a loop your current object from array will be a var "item". therefore u can reference item.id

Answers