Skip to content

Relative JSON-pointer extension #115

Closed
@epoberezkin

Description

@epoberezkin

The proposal is to extend relative JSON pointer (https://tools.ietf.org/html/draft-luff-relative-json-pointer-00) to be able to refer to the items in array with some relative position.

Originally filed as: json-schema/json-schema#223

The syntax extension can be really simple, from the current N/JSONpointer to N+M/JSONPointer (to traverse N levels up and M items forward) or N-M/JSONPointer (M items backward), where N == 0 can possibly be dropped.

That would allow, for example, to implement restrictions on the array such as ascending/descending order (using $data v5 proposal).

Ascending order without duplicates:

{
  "type": "array",
  "items": {
    "type": "integer",
    "minimum": { "$data": "-1/" },
    "exclusiveMinimum": true
  }
}

Objects ordered in ascending order by unique id property:

{
  "type": "array",
  "items": {
    "properties": {
      "id": {
        "type": "integer",
        "minimum": { "$data": "1-1/id" },
        "exclusiveMinimum": true
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions