JSON TransformArray
slice
Extract a contiguous portion of an array
slice
Returns the slice of an array between start (inclusive) and end (exclusive). Both indices are clamped to the array length, so out-of-range values are safe.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
start | integer | Yes | — | Inclusive start index. Negatives floor to 0. |
end | integer | No | array length | Exclusive end index. Negatives floor to 0. |
Example
Input
["a", "b", "c", "d", "e"]Operation
{ "type": "slice", "options": { "start": 1, "end": 4 } }Output
["b", "c", "d"]In a Circuit Step
{
"name": "take_window",
"description": "Take messages 1..3 from the conversation",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ messages }}",
"operations": [
{ "type": "slice", "options": { "start": 1, "end": 4 } }
]
},
"outputs": [
{
"name": "windowed_messages",
"description": "A 3-message slice of the input",
"value": "${{ take_window.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
slice: expected arrayif the input value is not an array. startis clamped to[0, len]andenddefaults tolen, so{ "start": 100 }returns[]rather than panicking.- Negative
start/endvalues are floored to0. There is no Python-style "from the end" support. sliceis non-destructive — it returns a new array and the input is left untouched.