Skip to main content

Namespace: jsonpath

Namespaces

Enumerations

Classes

References

FilterFunction

Re-exports FilterFunction


FunctionExpressionType

Re-exports FunctionExpressionType

Type Aliases

FilterContext

Ƭ FilterContext: Object

Object passed to FilterExpression.evaluate().

Type declaration

NameType
currentKey?string | number
currentValueJSONValue
environmentJSONPathEnvironment
lazy?boolean
rootValueJSONValue

Defined in

src/path/types.ts:14


JSONPathEnvironmentOptions

Ƭ JSONPathEnvironmentOptions: Object

JSONPath environment options. The defaults are in compliance with JSONPath standards.

Type declaration

NameTypeDescription
keysPattern?RegExpThe pattern to use for the non-standard keys selector. The lexer expects the sticky bit to be set. Defaults to /~/y.
maxIntIndex?numberThe maximum number allowed when indexing or slicing an array. Defaults to 2**53 -1.
maxRecursionDepth?numberThe maximum number of objects and/or arrays the recursive descent selector can visit before a JSONPathRecursionLimitError is thrown.
minIntIndex?numberThe minimum number allowed when indexing or slicing an array. Defaults to -(2**53) -1.
nondeterministic?booleanIf true, enable nondeterministic ordering when iterating JSON object data. This is mainly useful for validating the JSONPath Compliance Test Suite.
strict?booleanIndicates if the environment should to be strict about its compliance with RFC 9535. Defaults to true. Setting strict to false enables non-standard features. Non-standard features are subject to change if conflicting features are included in a future JSONPath standard or draft standard, or an overwhelming consensus amongst the JSONPath community emerges that differs from this implementation.

Defined in

src/path/environment.ts:27


JSONPathValue

Ƭ JSONPathValue: JSONValue | typeof Nothing

ValueType for JSONPath function expression tye system.

Defined in

src/path/types.ts:9

Variables

DEFAULT_ENVIRONMENT

Const DEFAULT_ENVIRONMENT: JSONPathEnvironment

Defined in

src/path/index.ts:32


KEY_MARK

Const KEY_MARK: "\u0002"

Defined in

src/path/types.ts:32


Nothing

Const Nothing: typeof Nothing

Defined in

src/path/types.ts:4

Functions

compile

compile(path): JSONPath

Compile JSONPath path for later use.

Parameters

NameTypeDescription
pathstringA JSONPath expression/query.

Returns

JSONPath

A path object with a query() method.

Throws

JSONPathSyntaxError If the path does not conform to standard syntax.

Throws

JSONPathTypeError If filter function arguments are invalid, or filter expression are used in an invalid way.

Defined in

src/path/index.ts:88


lazyQuery

lazyQuery(path, value): IterableIterator<JSONPathNode>

Lazily query JSON value value with JSONPath expression path. Lazy queries can be faster and more memory efficient when querying large datasets, especially when using recursive decent selectors.

Parameters

NameTypeDescription
pathstringA JSONPath expression/query.
valueJSONValueThe JSON-like value the JSONPath query is applied to.

Returns

IterableIterator<JSONPathNode>

A sequence of JSONPathNode objects resulting from applying path to value.

Throws

JSONPathSyntaxError If the path does not conform to standard syntax.

Throws

JSONPathTypeError If filter function arguments are invalid, or filter expression are used in an invalid way.

Defined in

src/path/index.ts:69


match

match(path, value): JSONPathNode | undefined

Return a JSONPathNode instance for the first object found in value matching path.

Parameters

NameTypeDescription
pathstringA JSONPath query.
valueJSONValueJSON-like data to which the query path will be applied.

Returns

JSONPathNode | undefined

The first node in value matching path, or undefined if there are no matches.

Defined in

src/path/index.ts:101


query

query(path, value): JSONPathNodeList

Query JSON value value with JSONPath expression path.

Parameters

NameTypeDescription
pathstringA JSONPath expression/query.
valueJSONValueThe JSON-like value the JSONPath query is applied to.

Returns

JSONPathNodeList

A list of JSONPathNode objects, one for each value matched by path in value.

Throws

JSONPathSyntaxError If the path does not conform to standard syntax.

Throws

JSONPathTypeError If filter function arguments are invalid, or filter expression are used in an invalid way.

Defined in

src/path/index.ts:48