Skip to main content

Class: JSONPathEnvironment

Defined in: src/path/environment.ts:60

Constructors​

Constructor​

new JSONPathEnvironment(options?): JSONPathEnvironment

Defined in: src/path/environment.ts:102

Parameters​

options?​

JSONPathEnvironmentOptions = {}

Environment configuration options.

Returns​

JSONPathEnvironment

Properties​

functions​

functions: object

Defined in: src/path/environment.ts:97

Index Signature​

[key: string]: FilterFunction


maxExpressionDepth​

readonly maxExpressionDepth: number

Defined in: src/path/environment.ts:87

The maximum number of nested expressions allowed in a query before a JSONPathRecursionError is thrown.


maxIntIndex​

readonly maxIntIndex: number

Defined in: src/path/environment.ts:75

The maximum integer allowed when indexing or slicing an array. Defaults to 2**53 -1.


maxRecursionDepth​

readonly maxRecursionDepth: number

Defined in: src/path/environment.ts:93

The maximum number of objects and/or arrays the descendant segment can visit before a JSONPathRecursionError is thrown.


minIntIndex​

readonly minIntIndex: number

Defined in: src/path/environment.ts:81

The minimum integer allowed when indexing or slicing an array. Defaults to -(2**53) -1.


parser​

readonly parser: ParserClass

Defined in: src/path/environment.ts:95


strict​

readonly strict: boolean

Defined in: src/path/environment.ts:69

Indicates if the environment should to be strict about its compliance with JSONPath standards.

Defaults to true. Setting strict to false enables the non-standard current key identifier, key selector, keys selector and keys filter selector.

Methods​

compile()​

compile(expression): JSONPathQuery

Defined in: src/path/environment.ts:116

Compile a JSONPath query expression for later evaluation.

Parameters​

expression​

string

Returns​

JSONPathQuery


find()​

find(expression, data): JSONPathNode[]

Defined in: src/path/environment.ts:123

Evaluate JSONPath query expression against data and return an array of matched nodes.

Parameters​

expression​

string

data​

JSONValue

Returns​

JSONPathNode[]


findAll()​

findAll(expression, data): JSONValue[]

Defined in: src/path/environment.ts:158

Evaluate JSONPath query expression against data and return an array of values.

Parameters​

expression​

string

data​

JSONValue

Returns​

JSONValue[]


findAllIter()​

findAllIter(expression, data): IterableIterator<JSONValue>

Defined in: src/path/environment.ts:168

Evaluate JSONPath query expression against data and generate values lazily.

Note that some queries will require internal iterators to be materialized into arrays, so peak memory usage might be higher than expected.

Parameters​

expression​

string

data​

JSONValue

Returns​

IterableIterator<JSONValue>


findIter()​

findIter(expression, data): IterableIterator<JSONPathNode>

Defined in: src/path/environment.ts:133

Evaluate JSONPath query expression against data and generate nodes lazily.

Note that some queries will require node iterators to be materialized into node lists, so peak memory usage might be higher than expected.

Parameters​

expression​

string

data​

JSONValue

Returns​

IterableIterator<JSONPathNode>


findOne()​

findOne(expression, data): JSONPathNode | undefined

Defined in: src/path/environment.ts:176

Evaluate JSONPath query expression against data and return the first matching node, or undefined if there were no matches.

Parameters​

expression​

string

data​

JSONValue

Returns​

JSONPathNode | undefined


lazyQuery()​

lazyQuery(expression, data): IterableIterator<JSONPathNode>

Defined in: src/path/environment.ts:151

Evaluate JSONPath query expression against data and generate nodes lazily.

Parameters​

expression​

string

data​

JSONValue

Returns​

IterableIterator<JSONPathNode>

Deprecated​

Use findIter instead.


match()​

match(expression, data): JSONPathNode | undefined

Defined in: src/path/environment.ts:186

Evaluate JSONPath query expression against data and return the first matching node, or undefined if there were no matches.

Parameters​

expression​

string

data​

JSONValue

Returns​

JSONPathNode | undefined

Deprecated​

Use findOne instead.


query()​

query(expression, data): JSONPathNode[]

Defined in: src/path/environment.ts:142

Evaluate JSONPath query expression against data and return an array of matched nodes.

Parameters​

expression​

string

data​

JSONValue

Returns​

JSONPathNode[]

Deprecated​

Use find instead.


setupFilterFunctions()​

protected setupFilterFunctions(): void

Defined in: src/path/environment.ts:202

A hook for setting up the function register. You are encouraged to override this method in classes extending JSONPathEnvironment.

Returns​

void


test()​

test(expression, data): boolean

Defined in: src/path/environment.ts:194

Return true if JSONPath query expression matches at least one node in data, or false otherwise.

Parameters​

expression​

string

data​

JSONValue

Returns​

boolean