%dw 2.0
output application/json
---
{ "myRange": 1 to 10 }
DataWeave
to
to(from: Number, to: Number): Range
Returns a range with the specified boundaries.
The upper boundary is inclusive.
Parameters
Name | Description |
---|---|
|
|
|
|
Example
This example lists a range of numbers from 1 to 10.
Source
Output
{ "myRange": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }
JSON
Example
DataWeave treats a string as an array of characters. This example applies to
to a string.
Source
%dw 2.0
var myVar = "Hello World!"
output application/json
---
{
indices2to6 : myVar[2 to 6],
indicesFromEnd : myVar[6 to -1],
reversal : myVar[11 to -0]
}
DataWeave
Output
{
"indices2to6": "llo W",
"indicesFromEnd": "World!",
"reversal": "!dlroW olleH"
}
JSON