โ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)