ModelWorks logoModelWorks
JSON TransformObject

keys

Return an object's keys as an array

keys

Returns an array containing the keys of the current object, in insertion order.

Options

This operation takes no options; pass an empty object or omit options entirely.

Example

Input

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

Operation

JSON
{ "type": "keys" }

Output

JSON
["id", "name", "active"]

In a Circuit Step

JSON
{
  "name": "list_field_names",
  "description": "List the top-level field names of the user object",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ user }}",
    "operations": [
      { "type": "keys" }
    ]
  },
  "outputs": [
    {
      "name": "user_field_names",
      "description": "Array of field names on the user object",
      "value": "${{ list_field_names.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with keys: expected object if the input is not an object.
  • Output order matches the underlying serde_json::Map insertion order, which preserves the JSON source order.
  • The output is an array, so subsequent operations should target arrays — common chains include keys → sort, keys → filter.
On this page

On this page