Skip to content

Extend array operations to also work on strings #28

Open
@mitar

Description

@mitar

As an alternative to #6 and #25 I would propose that operations are allowed to index into strings as well. This would allow one to modify parts of a string instead of sending the whole value over. Moreover, internally, strings are often seen as something you can index already, or are even arrays of characters.

So for a JSON like:

{"value": "foobar"}

A patch like:

[
  {"op": "replace", "path": "/value/0-3", "value": "no"}
]

Replacing first three characters with "no' and resulting in:

{"value": "nobar"}

So upper limit would be exclusive. You could also specify "2-" to select all characters from the 3rd character to the end.

I would not introduce a whole new set of string operations. And also do note that such pointer is uniquely determined given a type of the value at the path. So if it points to an array, 0-3 index into the array (for now I would leave such index invalid for arrays, but that could be a separate discussion), if it points to a string it index into the string. And if there is an object, it is simply a 0-3 property of the object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions