Skip to content

Value-based array operations #18

@heruan

Description

@heruan

Arrays should have value-based patch operations. Currently, only index-based actions are permitted:

  • insert by index or last;
  • replace by index;
  • remove by index.

The current spec lacks value-based operations on arrays, such as:

  • insert before/after certain existing values;
  • replace existing values;
  • remove by values.

For example, given:

{
    "items": [ "a", "c", "e", "z" ]
}

This patch should be valid:

[
    { "op": "add",     "path": "/items/-", "value": "b", "before": "c" },
    { "op": "replace", "path": "/items/-", "value": "d", "replace": "e" },
    { "op": "remove",  "path": "/items/-", "value": "z" }
]

And produce:

{
    "items": [ "a", "b", "c", "d" ]
}

The special - key, could be the indicator of an array at a specific path to keep compatibility with the current spec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions