Reputation: 9850
I am trying to convert an array to comma separated string using jolt transform. Is there a way to achieve this ?
{
"scores": [
"a",
"b",
"c",
"d",
"e"
]
}
Expected Output
{
"scores": "a,b,c,d,e"
}
Upvotes: 1
Views: 1695
Reputation: 2691
You can use join
with modify-overwrite-beta
operation.
[
{
"operation": "modify-overwrite-beta",
"spec": {
"scores": "=join(', ',@(1,scores))"
}
}
]
Upvotes: 1
Reputation: 11
you can try the following spec
[{ "operation": "modify-overwrite-beta",
"spec": { "scores":"=concat(@(2,scores[0]),',',@(2,scores[1]),',',@(2,scores[2]),',',@(2,scores[3]),',',@(2,scores[4]))" } }
]
Upvotes: 1