JSON TransformArray
map
Transform each element of an array using JMESPath
map
Projects each element of an array through a JMESPath expression. The current element is exposed as item and @.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
expression | string | Yes | — | JMESPath expression evaluated against each element. |
Example
Input
[
{ "role": "user", "content": "Hi" },
{ "role": "assistant", "content": "Hello" }
]Operation
{ "type": "map", "options": { "expression": "content" } }Output
["Hi", "Hello"]In a Circuit Step
{
"name": "extract_contents",
"description": "Project each message down to its content string",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ messages }}",
"operations": [
{ "type": "map", "options": { "expression": "content" } }
]
},
"outputs": [
{
"name": "message_texts",
"description": "Array of just the message contents",
"value": "${{ extract_contents.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
map: expected arrayif the input is not an array. - The expression runs in a per-element memory whose root is
{ "item": <element>, "@": <element> }. You can use either name, plus any JMESPath features. - Each evaluation that fails surfaces a
map: evaluation failed: ...error and aborts the operation. - For multi-field projections, use JMESPath multi-select-hash:
"expression": "{ id: id, name: name }". - See Expressions for full details and gotchas.