cancel
Showing results for 
Search instead for 
Did you mean: 

Snaplogic iterate over array

arunsadhasivam
New Contributor

Hi ,

i have json like
payload{
input:[
{url: "test.com’,}
{url: "test.com’,},
{url: "test.com’,}
]
}

i need to iterate over payload.input[0].url ,payload.input[1].url and send url to restPOST api.
can you please suggest anyoption to get individual url by iterate the url list

5 REPLIES 5

tstack
Former Employee

I think you’re looking for the JSONSplitter snap. The Splitter will break up the array into multiple documents that you can feed into a REST POST snap. You’ll probably want to configure the Splitter with a path like $payload.input[*]. You can include parts of the original document in the documents output by the Splitter using the “Include scalar parents” and “Include paths” options.

no i tried json-splitter but the thinhg is it is returning collection of url , i need one url from collection at a time and use that url should be in rest post . let me know any option. i need some thing like queue or forloop. i tried sequence which can generate a counter 1-n records but i could not keep iterate over it.
i am new to snaplogic, i see only option is push to queue . but iam looking for some option other than this .

let me know if any option i missed in json splitter which could allow loop over collection one at a time.

The Splitter should be doing that for you. Can you maybe take a screenshot of your pipeline and a separate one of the Splitter configuration that you were trying at the time. We can take a look and try to figure out what is going on.

Note that when building a pipeline, you’re trying to setup the different stages of processing that will be applied to the data that is flowing through it. There’s not really any looping going on. So, in your case, you’re receiving the data, maybe validating it, and then doing the REST POST. The Splitter is needed to reshape the data flow to expand the single input doc into multiple output docs that can go through the remaining stages of the pipeline.