Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ptr

Ptr represents a RFC6901 JSON Pointer.

Hierarchy

  • Ptr

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Ptr(tokens: string[]): Ptr
  • Constructs a Ptr directly from a sequence of pre-escaped tokens.

    Parameters

    • tokens: string[]

      The tokens making up the JSON Pointer.

    Returns Ptr

Properties

tokens

tokens: string[]

The set of tokens that make up a JSON Pointer. These tokens are already "un-escaped" -- that is, the special sequences "~0" and "~1" have already been convered to "~" and "/", respectively.

Methods

eval

  • eval(instance: any): any
  • Evaluates this JSON Pointer against an object, following the mechanism described in RFC 6901, Section 4.

    throws

    EvalError If the instance, or one of its descendants, doesn't have a property being referred to.

    Parameters

    • instance: any

      The object to dereference the JSON Pointer against.

    Returns any

toString

  • toString(): string
  • Converts a JSON Pointer back into its string representation. This function will handle converting any "~" or "/" in its tokens back into their escaped forms, as per RFC 6901, Section 3.

    Returns string

Static parse

  • parse(s: string): Ptr
  • Parse an inputted string as a JSON Pointer. This function will handle un-escaping the special sequences "~0" and "~1", as per RFC 6901, Section 3.

    throws

    InvalidPtrError If the input does not correspond to a valid JSON Pointer.

    Parameters

    • s: string

      The string to parse as a JSON Pointer.

    Returns Ptr

Generated using TypeDoc