JSONPath Tools / @jsonpath-tools/jsonpath / Segment
Class: Segment
Query segment.
Extends
Constructors
new Segment()
new Segment(
dotToken,
openingBracketToken,
selectors,
closingBracketToken,
segmentType): SegmentParameters
dotToken
Dot or double dot token, or null if not present.
null | SyntaxTreeToken
openingBracketToken
Opening bracket token, or null if not present.
null | SyntaxTreeToken
selectors
readonly object[]
Selectors
closingBracketToken
Closing bracket token, or null if not present.
null | SyntaxTreeToken
segmentType
Whether it is a child segment or a descendant segment.
Returns
Segment
Overrides
Properties
_parent
_parent: null | SyntaxTreeNode = null;Internal
Inherited from
children
readonly children: SyntaxTree[];Children.
Inherited from
closingBracketToken
readonly closingBracketToken: null | SyntaxTreeToken;Closing bracket token, or null if not present.
dotToken
readonly dotToken: null | SyntaxTreeToken;Dot or double dot token, or null if not present.
length
readonly length: number;Length in the text.
Inherited from
openingBracketToken
readonly openingBracketToken: null | SyntaxTreeToken;Opening bracket token, or null if not present.
position
readonly position: number;Position in the text.
Inherited from
segmentType
readonly segmentType: SegmentType;Whether it is a child segment or a descendant segment.
selectors
readonly selectors: readonly object[];Selectors
Accessors
parent
Get Signature
get parent(): null | SyntaxTreeNodeParent or null when no parent is assigned.
Returns
null | SyntaxTreeNode
Inherited from
skippedTextBefore
Get Signature
get skippedTextBefore(): stringText that was skipped during parsing.
Returns
string
Text that was skipped during parsing.
Inherited from
SyntaxTreeNode.skippedTextBefore
textRange
Get Signature
get textRange(): TextRangeRange in the text.
Returns
Inherited from
textRangeWithoutSkipped
Get Signature
get textRangeWithoutSkipped(): TextRangeRange in the text excluding skipped text before.
Returns
Inherited from
SyntaxTreeNode.textRangeWithoutSkipped
type
Get Signature
get type(): SyntaxTreeTypeType.
Returns
Type.
Overrides
usesBracketNotation
Get Signature
get usesBracketNotation(): booleanWhether the segment uses a bracket notation.
Returns
boolean
Methods
forEach()
forEach(action): voidExecutes 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
getAtPosition()
getAtPosition(characterPosition): null | SyntaxTreeReturns 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
null | SyntaxTree
Inherited from
getContainingAtPosition()
getContainingAtPosition(caretPosition): null | SyntaxTreeReturns 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
null | SyntaxTree
Inherited from
SyntaxTreeNode.getContainingAtPosition
getTouchingAtPosition()
getTouchingAtPosition(caretPosition): SyntaxTree[]Returns all innermost subtrees that touch the given caret position.
Parameters
caretPosition
number
Position (caret position index).
Returns
Inherited from
SyntaxTreeNode.getTouchingAtPosition
select()
select(
input,
output,
queryContext): voidSelects nodes from the input node to the output array.
Parameters
input
Input node.
output
Output nodes.
queryContext
Query context.
Returns
void