10-16-2018 06:28 AM
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:
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?
10-16-2018 08:03 AM
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.
10-16-2018 08:17 AM
can you share how i would use this snap with the data from above?
10-16-2018 10:37 AM
Here’s a full example of what @tstack described.
First group all the documents into a single document.
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')
Here is a copy of the pipeline if you want to experiment with it further.
groupby_2018_10_16.slp (5.6 KB)