2 Answers
- Newest
- Most votes
- Most comments
1
Yes, but not easily. You can iterate through the array of items you want to join using a Choice that flows to a Pass that uses States.Format to append each array item to a string. It's ugly, but it works.
- Create a Pass state that initializes the string accumulator and the number of items in the array, and flow to the Choice state below: Parameters: { "the_string": "", "item_count.$": "$.States.ArrayLength($.my_array)", "current_index": 0, "my_array.$": "$.my_array" }
- Create a choice state that tests the array length and current index to see if any items remain to be appended: Choices: [ { "Variable": "$.current_index", "NumericLessThanPath": "$.item_count", "Next": "Append an Item" } ]
- Create a Pass state that appends the string and increments the current index, and returns to the Choice state above: Parameters: { "the_string.$": "States.Format('{}your seprator here{}', $.the_string, $. )", "item_count.$": "$.item_count", "current_index.$": "States.MathAdd($.current_index, 1)", "my_array.$":"$.my_array" }
The Choice state will flow to the default Next state once all of the array items have been appended to $.the_string.
Hope that's clear enough.
answered 4 months ago
0
One option will be to use States.Format() and pass the array contents if the array length is fixed.
answered a year ago
Relevant content
- asked 5 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Thanks, unfortunately the output of an taskToken does not have an constant number of "+". I already thought about a loop which combines always 2 array values as long as there are more than 1 value in the array. But for an Standard function that's also pretty expensive. Would be nice if there is a native function to achieve that.