ModelWorks logoModelWorks
JSON TransformObject

entries

Convert an object into an array of [key, value] pairs

entries

Returns an array of two-element arrays, each containing a key and its value.

Options

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

Example

Input

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

Operation

JSON
{ "type": "entries" }

Output

JSON
[
  ["id", 1],
  ["name", "Ada"]
]

In a Circuit Step

JSON
{
  "name": "to_pairs",
  "description": "Convert the user object to a list of [key, value] pairs",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ user }}",
    "operations": [
      { "type": "entries" }
    ]
  },
  "outputs": [
    {
      "name": "user_entries",
      "description": "Array of [key, value] pairs",
      "value": "${{ to_pairs.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with entries: expected object if the input is not an object.
  • Output order matches the input key order.
  • Pairs nicely with map for per-entry transformations and with fromEntries to round-trip back to an object.
On this page

On this page