Max
2 years agoNew Contributor II
Divide a comma separated list of strings
Hello,
I have a requirement to convert the following MuleSoft dataweave code into snap logic...
rpns default '' splitBy ',' distinctBy $ divideBy 245 map ((item, index) -> 'searchCriteria': (item joinBy ','))
I will receive a json payload like below. I could receive hundreds of rpns and I need to divide the rpns list by 245
Example:
{
"searchCriteria":[
{
"keyName": "rpns",
"values": "DUCT123-P,DUCT234-FM,DUCT345-MM,DUCT456-P,DUCT567-MM,
DUCT678-A,DUCT789-FM,DUCT891-MM,DUCT901-P,DUCT012-MM"
}
]
}
In this example, I need to divide the rpns string above by 2, so I get 5 objects of 2 strings values each. Below is an example of expected output. Does anyone know how this can be accomplished? Thank you for your help.
Expected output:
[
{
"searchCriteria":
"DUCT123-P,DUCT234-FM"
},
{
"searchCriteria":
"DUCT345-MM,DUCT456-P"
},
{
"searchCriteria":
"DUCT567-MM,DUCT678-A"
},
{
"searchCriteria":
"DUCT789-FM,DUCT891-MM"
},
{
"searchCriteria":
"DUCT901-P,DUCT012-MM"
}
]