Expand my Community achievements bar.

How to remove keys from a complex array

Avatar

Level 4

If I have an array of collections with key-value pairs, what's the easiest way to transform this array so that only certain keys (and their values) are preserved in the array?

For example, if this is the output of a HTTP request module:

tibormolnar_0-1761426638625.png

how can I transform this data so that within each collection I have only the value and label keys?

I'd like to store the transformed array in a variable so that I can later "search" within that with the map function.

Thank you!

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Reply

Avatar

Level 2

@tibormolnar 

Based on my understanding, you want label & value from collection and create a new simplified array. 

You can achieve this by mapping items into a new array & using map function.

Source : https://experienceleague.adobe.com/en/docs/workfront-fusion/using/create-scenarios/map-data/map-an-a...

This will help you define exactly which fields you want to include in your new array structure.

If this helps, please mark this as Correct answer so others can benefit too!