I am trying to generate an array like below using dataweave with two dynamic input i.e totalCount=1000 and splitNumber=100 in mule . I am able to do the same in Java script but not sure how to achieve this in dataweave.
{ start: 1, end: 100 },
{ start: 101, end: 200 },
{ start: 201, end: 300 },
{ start: 301, end: 400 },
{ start: 401, end: 500 },
{ start: 501, end: 600 },
{ start: 601, end: 700 },
{ start: 701, end: 800 },
{ start: 801, end: 900 },
{ start: 901, end: 1000 }
You can try iterating (n - 1)
times where n is totalCount/splitNumber i.e. 9 times
If you are expecting in json array format then try with changing output type to application/json
%dw 2.0
output application/x-ndjson
var totalCount=1000
var splitNumber=100
---
0 to ((totalCount/splitNumber)-1) map(item,index)->{
"start": (splitNumber * item) + 1,
"end": (item + 1) * splitNumber
}