04-21-2021 08:23 AM
I am looking for a solution to concat all the field values from multiple row into single separated by delimited symbol ‘!’.
Input data:
[
{“Record”: “1”},
{“Record”: “2”},
{“Record”: “5”},
{“Record”: “4”},
{“Record”: “6”}
]
Expected Output:
[
{“Records”: “1!2!5!4!6”}
]
Solved! Go to Solution.
04-21-2021 08:42 AM
Hi @smeitei ,
First you need to group all input documents into a single array. For that you can use the Group by N snap with the setting “Group size” seto to 0. Then use a mapper with the following expression: jsonPath($, "Records[*]").map(val => val.get("Record")).join("!")
Output:
You can also use the Aggregate snap, but this will use the default delimeter.
04-21-2021 08:42 AM
Hi @smeitei ,
First you need to group all input documents into a single array. For that you can use the Group by N snap with the setting “Group size” seto to 0. Then use a mapper with the following expression: jsonPath($, "Records[*]").map(val => val.get("Record")).join("!")
Output:
You can also use the Aggregate snap, but this will use the default delimeter.
04-22-2021 12:46 AM
@j.angelevski - Thanks for you input and it works.
04-21-2021 08:58 AM
Another one solution for this.
jsonPath($, "$group[*].Record").reduce((acc, curr) => acc + "!" + curr)