Looking Up Data from One Array to a Second Array

Hello all, thank you for the great resource that this forum is.
I am looking for some assistance in looking up variables.

For example, if I have an "Array1" that returns:

[
{"id":1,"name":"abc,"label_ids":1},
{"id":2,"name":"def","label_ids":2},
{"id":3,"name":"ghi","label_ids":3}
]

I can save these into something like global.lookup

Now if I have another Array2 from a different endpoint that returns:

{"id"1234,"label_ids":[1,2,3]}

How do I look up the name on the Array2 from the global.lookup
Ideally I would like to convert all the label_ids to each contain and array with "id" and "name"
At the minimum I would like replace the "label_ids" in Array2 with "name" from Array1 for the entire array.
I could do it with If statements, but it is really messy especially if new labels get added.
Thank you very much for your assistance.

Hi @CHR1ST00

before diving into code, could you provide an example of the output you'd like given the example inputs you've shared? Helps to avoid any misinterpretation of what you've written.

Hello knolleary,

Thank you for your reply
According to my example above
Instead of :

{"id"1234,"label_ids":[1,2,3]}

I would like:

{"id"1234,"label_ids":
[
{"label_ids":"label_ids"},
{"label_ids":"name"}
]}

Not sure if I have explained that exceptionally well.