JSON TransformArray
chunk
Split an array into fixed-size chunks
chunk
Splits an array into successive chunks of size. The final chunk may be shorter if the array length isn't a multiple of size.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
size | integer | Yes | — | Chunk size (must be > 0). |
Example
Input
[1, 2, 3, 4, 5, 6, 7]Operation
{ "type": "chunk", "options": { "size": 3 } }Output
[[1, 2, 3], [4, 5, 6], [7]]In a Circuit Step
{
"name": "batch_records",
"description": "Split records into batches of 50 for downstream processing",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ records }}",
"operations": [
{ "type": "chunk", "options": { "size": 50 } }
]
},
"outputs": [
{
"name": "record_batches",
"description": "Records grouped into batches of up to 50 each",
"value": "${{ batch_records.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
chunk: expected arrayif the input is not an array. - A
sizeof0will panic at the slice level — always pass a positive integer. - The trailing chunk is included as-is even when shorter than
size. There is no padding option; pad upstream withpushif you need fixed-size groups. - The output is an array of arrays. Pair with
mapto apply a transformation per chunk.