cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Make a list from multiple documents

matt_bostrom
New Contributor II

I have a need to create a single list from multiple documents. Here is an example of some JSON:

[
{
color: โ€œtest1โ€,
value: โ€œ111โ€
},
{
color: โ€œtest2โ€,
value: โ€œ222โ€
},
{
color: โ€œtest3โ€,
value: โ€œ333โ€
},
{
color: โ€œtest4โ€,
value: โ€œ444โ€
},
{
color: โ€œtest5โ€,
value: โ€œ555โ€
},
{
color: โ€œtest6โ€,
value: โ€œ666โ€
},
{
color: โ€œtest7โ€,
value: โ€œ777โ€
}
]

and it looks like this:
image

But I need to map all those documents into a single list that essentially looks like this to use in an IN statement:

โ€™ 111โ€™,โ€˜222โ€™,โ€˜333โ€™,โ€˜444โ€™,โ€˜555โ€™,โ€˜666โ€™,โ€˜777โ€™

How would I achieve this?

3 REPLIES 3

tstack
Former Employee

I think youโ€™re looking for the GroupByN snap. You can set the Group Size to zero to have it consume all of the documents.

matt_bostrom
New Contributor II

can you share how i would use this snap with the data from above?

tlikarish
Employee
Employee

Hereโ€™s a full example of what @tstack described.

First group all the documents into a single document.
image

Then select all the values into a single list using a mapper. Here is an expression that uses the jsonPath function to select all the value from the document.

jsonPath($, '$.group[*].value')

image

Here is a copy of the pipeline if you want to experiment with it further.

groupby_2018_10_16.slp (5.6 KB)