Skip to content

Alternative: Relative JSON Pointer should allow starting from after last array item #1236

Open
@handrews

Description

@handrews

This is an alternative proposal to #1235 (specifying evaluation of Relative JSON Pointer relative to JSON Pointer).

The feature that currently can't be implemented is using # to get the length of an array by applying it to - (which evaluates to the last index of the array plus one, a.k.a. its length). With what is proposed in #1235, resolving 0# against /- on the instance [0, 1, 2, 3] would result in 4.

Alternatively, the spec could be changed to allow starting with an instance location, or with the not-actually-present location of one beyond the current maximum index of an array.

Having looked at an implementation that relies on parent links being present in the de-serialized JSON structure, it would be a bit awkward to implement this in that approach. On the other hand, if you do have parent links, requiring re-evaluation from the root after resolving against a base pointer is also somewhat awkward (although note that #1235 does NOT propose requiring resolving against a base pointer, just also supporting it).

Anyway, just wanted to offer an alternate solution and note that I'm more interested in being able to use a relative pointer to get the length of an array than I am in how it is supported by the spec, or implemented by code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    In Discussion

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions