'How to convert an array of Strings into a String with a separator string in Mule

I have an array that I want to append only at the end of of each line; The array looks like this;

[
    "9011fc3g-8c8d-43f5-abc7-147845cbdd63",
    "fg8aeb41-210z-49d7-aa25-19da525b6b89",
    "8eb39er-d8g7-462c-9b69-1d5a1e3bf994",
    "67af209a-7535-4f51-95fd-284e2faea223",
    "5b93cf0d-e197-4cea-914b-3742c3aa0847",
    "fe80df52-5427-111f-8fe4-3d510e1857ba",
    "9c3e3323-e52e-44f2-9g34-45ebf93e05e7",
    "33e102e5-bs96-4e5c-ba72-55a5511d1d6f",
    "9197a16d-a263-42ae-a7a3-4ab58dbc4558"
]

an I want it to be like this;

9011fc3g-8c8d-43f5-abc7-155845cbdd63 or id eq
fg8aeb41-210z-49d7-aa25-25da525b6b89 or id eq
8eb39er2-d8g7-462c-9b69-d5a1e3bf994d or id eq
67af209a-7535-4f51-95fd-284e2faea223 or id eq
5b93cf0d-e197-4cea-914b-3742c3aa0847 or id eq
fe80df52-5427-111f-8fe4-3d510e1857ba or id eq
9c3e3323-e52e-44f2-9g34-45ebf93e05e7 or id eq
33e102e5-bs96-4e5c-ba72-55a5511d1d6f or id eq
9197a16d-a263-42ae-a7a3-4ab58dbd1d6f

So append each line with "or id eq" condition and remove all the double quotes, single quote and brackets. I tried with grouping and non catch grouping like this but its not working ([|"|]|,)

Thanks for helping.



Solution 1:[1]

%dw 2.0
output application/json
var payload = [
    "9011fc3g-8c8d-43f5-abc7-147845cbdd63",
    "fg8aeb41-210z-49d7-aa25-19da525b6b89",
    "8eb39er-d8g7-462c-9b69-1d5a1e3bf994",
    "67af209a-7535-4f51-95fd-284e2faea223",
    "5b93cf0d-e197-4cea-914b-3742c3aa0847",
    "fe80df52-5427-111f-8fe4-3d510e1857ba",
    "9c3e3323-e52e-44f2-9g34-45ebf93e05e7",
    "33e102e5-bs96-4e5c-ba72-55a5511d1d6f",
    "9197a16d-a263-42ae-a7a3-4ab58dbc4558"
]
---
payload reduce ($$ ++ " or id eq " ++ $)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MrM