JSON TransformObject
renameKey
Rename a single top-level key
renameKey
Renames a top-level key from from to to, preserving the value.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
from | string | Yes | — | Existing key name. |
to | string | Yes | — | New key name. |
Example
Input
{ "user_id": 1, "name": "Ada" }Operation
{ "type": "renameKey", "options": { "from": "user_id", "to": "id" } }Output
{ "name": "Ada", "id": 1 }In a Circuit Step
{
"name": "rename_user_id_field",
"description": "Rename `user_id` to `id` to match the downstream schema",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ record }}",
"operations": [
{ "type": "renameKey", "options": { "from": "user_id", "to": "id" } }
]
},
"outputs": [
{
"name": "normalized_record",
"description": "Record with `user_id` renamed to `id`",
"value": "${{ rename_user_id_field.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
renameKey: expected objectif the input is not an object. - If
fromdoesn't exist the operation is a no-op. - If
toalready exists it is overwritten by the value atfrom. - The renamed key moves to the end of the key order (because the implementation removes-then-inserts). To rename in-place at the same position, fall back to
entries → map → fromEntries. - Only top-level renames are supported. For nested keys, combine
unsetandset.