ModelWorks logoModelWorks
JSON TransformArray

removeAt

Remove elements at specific indices

removeAt

Removes the elements at every index in indices. The result preserves the order of the surviving elements.

Options

OptionTypeRequiredDefaultDescription
indicesarray<integer>YesZero-based indices to remove. Out-of-range ignored.

Example

Input

JSON
["a", "b", "c", "d", "e"]

Operation

JSON
{ "type": "removeAt", "options": { "indices": [1, 3] } }

Output

JSON
["a", "c", "e"]

In a Circuit Step

JSON
{
  "name": "drop_flagged_indices",
  "description": "Drop messages at the indices marked for removal",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ messages }}",
    "operations": [
      { "type": "removeAt", "options": { "indices": [1, 3] } }
    ]
  },
  "outputs": [
    {
      "name": "trimmed_messages",
      "description": "Messages with indices 1 and 3 removed",
      "value": "${{ drop_flagged_indices.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with removeAt: expected array if the input is not an array.
  • indices is deduplicated internally — listing an index twice is harmless.
  • All indices are interpreted against the original array, not against an iteratively shrinking one (so you don't have to compensate for already-removed earlier indices).
  • Out-of-range indices are silently ignored.
  • To remove by condition, use filter with the inverted predicate.
On this page

On this page