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)