JSONPath Tools / @jsonpath-tools/jsonpath / JSONPath
Class: JSONPath
JSONPath evaluator compliant with standard RFC 9535.
Methods
parse()
static parse(queryText, queryOptions): Query
Parses the given query for later execution or analysis.
Parameters
queryText
string
Text of the query.
queryOptions
QueryOptions
= defaultQueryOptions
Query options.
Returns
Parsed query (syntax tree).
Throws
JSONPathError When the query is not well-formed or valid.
remove()
static remove(
queryText,
queryArgument,
queryOptions): undefined | JSONValue
Executes the given query and removes the selected nodes from the query argument.
Parameters
queryText
string
Text of the query.
queryArgument
Argument of the query (JSON value the query is applied to).
queryOptions
QueryOptions
= defaultQueryOptions
Query options.
Returns
undefined
| JSONValue
Query argument with removed values.
Throws
JSONPathError When the query is not well-formed or valid.
replace()
static replace(
queryText,
queryArgument,
replacer,
queryOptions): undefined | JSONValue
Executes the given query and replaces the selected nodes in the query argument with the specified value.
Parameters
queryText
string
Text of the query.
queryArgument
Argument of the query (JSON value the query is applied to).
replacer
JSON value that should be used as a replacement or a function to create that value based on the replaced value.
JSONValue
| (value
) => JSONValue | undefined
queryOptions
QueryOptions
= defaultQueryOptions
Query options.
Returns
undefined
| JSONValue
Query argument with replaced values.
Throws
JSONPathError When the query is not well-formed or valid.
select()
static select(
queryText,
queryArgument,
queryOptions): NodeList
Executes the given query and returns the selected nodes.
Parameters
queryText
string
Text of the query.
queryArgument
Argument of the query (JSON value the query is applied to).
queryOptions
QueryOptions
= defaultQueryOptions
Query options.
Returns
Selected nodes.
Throws
JSONPathError When the query is not well-formed or valid.