- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 11:19 AM
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 load into the DB.
But my requirement is to also store the Array Index number of each record from the Array along with the data. I tried using the Array function named findIndex(), but in vain.
I would really appreciate if i get a solution for this issue.
Thanks
Aravind N
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 11:51 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2020 10:37 AM
@cjhoward18 For other array i tried to use the below function and it is returning 0 for all the indexes. Not sure what mistake i am doing. Please help
$entity.items.map(value => value.extend({‘Data_Ind’:$entity.items.indexOf(value)}))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2020 11:06 AM
Can you give the example input data and expected output you are trying to achieve please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 12:24 PM
Also, for the below screesnshot, i want to take the index as to how many responses returned. Since this is at the root level i tried $.map(value => value.extend({‘Batch_Index’:$.indexOf(value)})), but it is giving me an an error as
“Map type does not have a method named: map, found in: …dexOf(value)})). Perhaps you meant: mapKeys, mapValues”"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 08:37 PM
@cjhoward18 Just wanted to check if the array is split using json splitter can we have sequence snap so documents flowing will generate sequence number for rows?
Just checking if there are multiple options for this problem to expand more implementation methods.
