Metreeca Gear
    Preparing search index...

    Type Alias JPath

    JPath: (path: string) => readonly Value[]

    JSONPath-like selector over JSON values.

    Selects the values held by a fixed set of target JSON values, addressing them with a JSONPath-like syntax. The target set is settled when the selector is created and cannot be changed afterwards.

    Type Declaration

      • (path: string): readonly Value[]
      • Selects values.

        A single selection reaches across the whole target set: the values retrieved from each target are merged into one list, sparing the caller a loop of its own.

        A path chains steps, each selecting from the values the preceding one selected and written straight after it, with no separator beyond the leading . some steps carry:

        • $ — the target value itself; allowed only as the leading step, where it may be omitted
        • .property / property — object property
        • ['property'] — object property, with JSON string escapes read leniently: an unaccounted escape stands for the character it introduces, so \' names an apostrophe
        • [0] — array element by index
        • .* / [*] — every element of an array or every property value of an object

        Arrays are entered only through an index or a wildcard step, so a path reaching the properties of the objects held by an array must include an explicit [*] or .* step.

        Only values a JSON document may state are selected: null is selected as the value it states, while undefined, which only a value assembled in code carries, is passed over exactly as an absent property is.

        Parameters

        • path: string

          The selection path; an empty path or $ selects the target values unchanged

        Returns readonly Value[]

        An immutable list of the values selected by path, ordered by target and, within each target, in document order; empty if path selects no value

        SyntaxError If path is malformed