Forum Discussion

arvindnsn's avatar
arvindnsn
Contributor
5 years ago
Solved

How to get Index of Array list along with the data

Hello, I am working on API’s and while pulling the data from API and storing in the DB. The API is returning data in Arrays and while using the splitter i am able to split the data of arrays and lo...
  • cjhoward18's avatar
    cjhoward18
    5 years ago

    Yes, indexOf() returns the index not the value.

    Using your example data in a json generator, and a mapper with this expression:
    $items.map(value => value.extend({'Data_Index':$items.indexOf(value)}))

    you will see that the original map uses extend to add the index of each element to a new field ‘Data_Index’ in each value in the list.