Class: JSONPathEnvironment
Defined in: src/path/environment.ts:79
A configuration object from which JSONPath queries can be evaluated.
An environment is where you'd register custom function extensions or set the maximum recursion depth limit, for example.
Constructors
new JSONPathEnvironment()
new JSONPathEnvironment(
options
):JSONPathEnvironment
Defined in: src/path/environment.ts:129
Parameters
options
JSONPathEnvironmentOptions
= {}
Environment configuration options.
Returns
Properties
functionRegister
functionRegister:
Map
<string
,FilterFunction
>
Defined in: src/path/environment.ts:122
A map of function names to objects implementing the FilterFunction interface. You are free to set or delete custom filter functions directly.
keysPattern
readonly
keysPattern:RegExp
Defined in: src/path/environment.ts:116
The pattern to use for the non-standard keys selector.
maxIntIndex
readonly
maxIntIndex:number
Defined in: src/path/environment.ts:94
The maximum number allowed when indexing or slicing an array. Defaults to 2**53 -1.
maxRecursionDepth
readonly
maxRecursionDepth:number
Defined in: src/path/environment.ts:106
The maximum number of objects and/or arrays the recursive descent selector
can visit before a JSONPathRecursionLimitError
is thrown.
minIntIndex
readonly
minIntIndex:number
Defined in: src/path/environment.ts:100
The minimum number allowed when indexing or slicing an array. Defaults to -(2**53) -1.
nondeterministic
readonly
nondeterministic:boolean
Defined in: src/path/environment.ts:111
If true
, enable nondeterministic ordering when iterating JSON object data.
strict
readonly
strict:boolean
Defined in: src/path/environment.ts:88
Indicates if the environment should to be strict about its compliance with JSONPath standards.
Defaults to true
. Setting strict
to false
currently has no effect.
If/when we add non-standard features, the environment's strictness will
control their availability.
Methods
checkWellTypedness()
checkWellTypedness(
token
,args
):FilterExpression
[]
Defined in: src/path/environment.ts:219
Check the well-typedness of a function's arguments at compile-time.
This method is called by the parser when parsing function calls. It is expected to throw a JSONPathTypeError if the function's parameters are not well-typed.
Override this if you want to deviate from the JSONPath Spec's function extension type system.
Parameters
token
The Token starting the function call. Token.value
will contain the name of the function.
args
One FilterExpression for each argument.
Returns
compile()
compile(
path
):JSONPathQuery
Defined in: src/path/environment.ts:145
Parameters
path
string
A JSONPath query to parse.
Returns
A new JSONPathQuery object, bound to this environment.
entries()
entries(
obj
): [string
,JSONValue
][]
Defined in: src/path/environment.ts:304
Return an array of key/values of the enumerable properties in obj.
If you want to introduce some nondeterminism to iterating JSON-like
objects, do it here. The wildcard selector, descendent segment and
filter selector all use this.environment.entries
.
Parameters
obj
A JSON-like object.
Returns
[string
, JSONValue
][]