Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JSONPointer

JSON Pointer implementation that allows incremental building of pointers.

param

Segments from parent context

since

5.9

Hierarchy

  • JSONPointer

Index

Constructors

constructor

  • Create a JSONPointer

    Parameters

    • segments: Segment[]

      segments from parent context

    Returns JSONPointer

Properties

Readonly segments

segments: Segment[]

The path segments

Methods

equalIgnoringIndexes

  • Returns whether this JSONPointer is equal to another JSONPointer, ignoring the values of array index segments.

    This implements an equivalence relation between JSONPointers that considers two values equal if they have the same number of segments, corresponding segments are of the same type, and corresponding key segments are equal. It is used by the structural delta code to identify potential matches between two pointers to different values.

    Parameters

    Returns boolean

    whether the other pointer is equal (ignoring indexes)

equals

  • Compare two JSONPointer objects

    Non-equal JSONPointer instances can have the same expression. E.g. ROOT.withIndex(1) is not equal to ROOT.withKey('1'), but both have the same expression '/1'

    Parameters

    • other: JSONPointer

      the other pointer instance to compare to

    Returns boolean

    whether the two instances are equal

toString

  • toString(): string
  • Convert the JSON pointer to a string

    Returns string

    the JSONPointer expression

withIndex

  • Append a index segment to the pointer

    Parameters

    • index: number

    Returns JSONPointer

    a new instance equal to this instance with index appended

withKey

  • Append a key segment to the pointer

    Parameters

    • key: string

    Returns JSONPointer

    a new instance equal to this instance with key appended

withSegment

  • Append a segment to the pointer

    Parameters

    Returns JSONPointer

    a new instance equal to this instance with segment appended

Static parse

  • Parse a string containing a JSON pointer into a JSONPointer object.

    A segment that has only decimal digits will be interpreted as an index unless it has leading zeros (RFC 6901, section4), or its value is larger than Integer.MAX_VALUE

    throws

    an IllegalArgumentError if the expression is not correctly formatted

    Parameters

    • expression: string | JSONPointer

      a string containing the JSON pointer expression. If a JSONPointer object is supplied, then it will be returned unchanged

    Returns JSONPointer

    a JSONPointer that corresponds to the expression

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.