Skip to content

JSONPath Tools / @jsonpath-tools/jsonpath / SubQuery

Class: SubQuery ​

Query.

Extends ​

Constructors ​

Constructor ​

ts
new SubQuery(
   identifierToken, 
   segments, 
   queryType): SubQuery;

Parameters ​

identifierToken ​

SyntaxTreeToken

Preceding root or current identifier.

segments ​

readonly Segment[]

Segments.

queryType ​

QueryType

Whether it is an absolute query or a relative query.

Returns ​

SubQuery

Overrides ​

SyntaxTreeNode.constructor

Properties ​

_parent ​

ts
_parent: SyntaxTreeNode | null = null;

Internal

Inherited from ​

SyntaxTreeNode._parent


children ​

ts
readonly children: SyntaxTree[];

Children.

Inherited from ​

SyntaxTreeNode.children


identifierToken ​

ts
readonly identifierToken: SyntaxTreeToken;

Preceding root or current identifier.


length ​

ts
readonly length: number;

Length in the text.

Inherited from ​

SyntaxTreeNode.length


position ​

ts
readonly position: number;

Position in the text.

Inherited from ​

SyntaxTreeNode.position


queryType ​

ts
readonly queryType: QueryType;

Whether it is an absolute query or a relative query.


segments ​

ts
readonly segments: readonly Segment[];

Segments.

Accessors ​

isSingular ​

Get Signature ​

ts
get isSingular(): boolean;

Whether it is a singular query as per the JSONPath specification.

Returns ​

boolean


parent ​

Get Signature ​

ts
get parent(): SyntaxTreeNode | null;

Parent or null when no parent is assigned.

Returns ​

SyntaxTreeNode | null

Inherited from ​

SyntaxTreeNode.parent


skippedTextBefore ​

Get Signature ​

ts
get skippedTextBefore(): string;

Text that was skipped during parsing.

Returns ​

string

Text that was skipped during parsing.

Inherited from ​

SyntaxTreeNode.skippedTextBefore


textRange ​

Get Signature ​

ts
get textRange(): TextRange;

Range in the text.

Returns ​

TextRange

Inherited from ​

SyntaxTreeNode.textRange


textRangeWithoutSkipped ​

Get Signature ​

ts
get textRangeWithoutSkipped(): TextRange;

Range in the text excluding skipped text before.

Returns ​

TextRange

Inherited from ​

SyntaxTreeNode.textRangeWithoutSkipped


type ​

Get Signature ​

ts
get type(): SyntaxTreeType;

Type.

Returns ​

SyntaxTreeType

Type.

Overrides ​

SyntaxTreeNode.type

Methods ​

forEach() ​

ts
forEach(action): void;

Executes the given action for this and all descendant trees in a pre-order tree traversal.

Parameters ​

action ​

(tree) => boolean | void

Action.

Returns ​

void

Inherited from ​

SyntaxTreeNode.forEach


getAtPosition() ​

ts
getAtPosition(characterPosition): SyntaxTree | null;

Returns the innermost subtree that spans the given character position or null when the position is outside of a range of the current tree.

Parameters ​

characterPosition ​

number

Position (character index).

Returns ​

SyntaxTree | null

Inherited from ​

SyntaxTreeNode.getAtPosition


getContainingAtPosition() ​

ts
getContainingAtPosition(caretPosition): SyntaxTree | null;

Returns the innermost subtree that fully contains the given caret position (not just touches) or null when the position is not contained in a range of the current tree.

Parameters ​

caretPosition ​

number

Position (caret position index).

Returns ​

SyntaxTree | null

Inherited from ​

SyntaxTreeNode.getContainingAtPosition


getTouchingAtPosition() ​

ts
getTouchingAtPosition(caretPosition): SyntaxTree[];

Returns all innermost subtrees that touch the given caret position.

Parameters ​

caretPosition ​

number

Position (caret position index).

Returns ​

SyntaxTree[]

Inherited from ​

SyntaxTreeNode.getTouchingAtPosition


select() ​

ts
select(queryContext, filterExpressionContext): NodeList;

Selects nodes from the given query argument.

Parameters ​

queryContext ​

QueryContext

Query context.

filterExpressionContext ​

| FilterExpressionContext | null

Filter expression context for a relative query or null for an absolute query.

Returns ​

NodeList


toNormalizedPath() ​

ts
toNormalizedPath(): NormalizedPath | null;

Converts the query to NormalizedPath. Returns null when the query does not represent a normalized path.

Returns ​

NormalizedPath | null