ModelWorks logoModelWorks
JSON TransformObject

pick

Keep only the specified keys of an object

pick

Returns a new object containing only the keys listed in keys (when present in the input). Order in the output follows the order of keys.

Options

OptionTypeRequiredDefaultDescription
keysarray<string>YesTop-level keys to retain.

Example

Input

JSON
{ "id": 1, "name": "Ada", "email": "ada@example.com", "secret": "shh" }

Operation

JSON
{ "type": "pick", "options": { "keys": ["id", "name"] } }

Output

JSON
{ "id": 1, "name": "Ada" }

In a Circuit Step

JSON
{
  "name": "project_user_summary",
  "description": "Keep only the public-safe user fields",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ user }}",
    "operations": [
      { "type": "pick", "options": { "keys": ["id", "name"] } }
    ]
  },
  "outputs": [
    {
      "name": "user_summary",
      "description": "User object reduced to id and name",
      "value": "${{ project_user_summary.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with pick: expected object if the input is not an object.
  • Missing keys are silently skipped, not filled with null. Use defaults to fill missing keys.
  • pick only inspects top-level keys. For nested projection, chain pick with set / unset, or use map over an array of objects.
On this page

On this page