ModelWorks logoModelWorks
JSON TransformObject

fromEntries

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

fromEntries

Inverse of entries. Builds an object from an array of two-element arrays where the first element is the key (string) and the second is the 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": "fromEntries" }

Output

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

In a Circuit Step

JSON
{
  "name": "rebuild_object",
  "description": "Reassemble [key, value] pairs into an object",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ user_entries }}",
    "operations": [
      { "type": "fromEntries" }
    ]
  },
  "outputs": [
    {
      "name": "rebuilt_user",
      "description": "Object reconstructed from key-value pairs",
      "value": "${{ rebuild_object.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with fromEntries: expected array if the input is not an array.
  • Each entry must be an array with at least two elements and the first must be a string. Entries violating either rule are silently skipped.
  • Duplicate keys are resolved by "last write wins" — later entries overwrite earlier ones.
  • Useful for the entries → map → fromEntries pattern: rename / rewrite values en masse.
On this page

On this page