如何将数组动态拆分为多个字符串

时间:2018-11-27 19:15:08

标签: dataweave

输入:{   “ID”: [     1,2,3,4,5,6,7,8,9,10   ] }

输出:{ “ID”: [ “ 1,2,3”, “ 4,5,6”, “ 7,8,9”, “ 10” ] }

%dw 2.0
output application/json
---
"id": vars.pd.*id joinBy ","

1 个答案:

答案 0 :(得分:2)

您可以在divideBy模块中使用dw::core::Arrays功能。

%dw 2.0
import * from dw::core::Arrays
output application/json
---
"id": payload.id divideBy 3 map ((v) -> v joinBy ",")