JSON TransformObject
defaults
Fill missing keys from a defaults object
defaults
Inserts each key from defaults into the current object only if the key is not already present. Existing values are never overwritten.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
defaults | object | Yes | — | Object whose keys provide fallback values. |
Example
Input
{ "model": "gpt-4o-mini", "temperature": 0.7 }Operation
{
"type": "defaults",
"options": {
"defaults": {
"model": "gpt-4-turbo",
"temperature": 0.2,
"max_tokens": 1024
}
}
}Output
{ "model": "gpt-4o-mini", "temperature": 0.7, "max_tokens": 1024 }In a Circuit Step
{
"name": "fill_config_defaults",
"description": "Backfill any missing config fields with sensible defaults",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ input.config }}",
"operations": [
{
"type": "defaults",
"options": {
"defaults": {
"model": "gpt-4-turbo",
"temperature": 0.2,
"max_tokens": 1024
}
}
}
]
},
"outputs": [
{
"name": "config_with_defaults",
"description": "Config object with defaults applied to missing fields",
"value": "${{ fill_config_defaults.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
defaults: expected objectif the input is not an object. - Keys present in the input retain their original value, even if that value is
nullor an empty string. The check is "key exists", not "value is truthy". - For deep defaulting (filling nested keys without overwriting existing ones), pre-merge with
mergewhere the default object is on the left of the chain — i.e., setsourceto the defaults andmergethe input on top, then keep the result. defaultsvalues are used as-is (not selector-evaluated). If you need selector resolution in default values, apply amergeoperation with the selectors resolved upstream.