json-p3
Version:
JSONPath, JSON Pointer and JSON Patch
43 lines (42 loc) • 1.67 kB
TypeScript
import { JSONPathEnvironment } from "./environment";
import { JSONPathNode, JSONPathNodeList } from "./node";
import { JSONValue } from "../types";
import { JSONPathSegment } from "./segments";
import { SerializationOptions } from "./types";
/**
* A compiled JSONPath query ready to be applied to different data repeatedly.
*/
export declare class JSONPathQuery {
readonly environment: JSONPathEnvironment;
readonly segments: JSONPathSegment[];
constructor(environment: JSONPathEnvironment, segments: JSONPathSegment[]);
/**
* Apply this JSONPath query to _value_.
* @param value - A JSON-like object to apply this query to.
* @returns Nodes matched by applying this query to _value_.
*/
query(value: JSONValue): JSONPathNodeList;
/**
* Apply this JSONPath query to _value_.
* @param value - A JSON-like object to apply this query to.
* @returns An iterator over nodes matched by applying this query to _value_.
*/
lazyQuery(value: JSONValue): IterableIterator<JSONPathNode>;
/**
* Return a {@link JSONPathNode} instance for the first object found in
* _value_ matching this query.
*
* @param value - JSON-like data to which this query will be applied.
* @returns The first node in _value_ matching this query, or `undefined` if
* there are no matches.
*/
match(value: JSONValue): JSONPathNode | undefined;
/**
* Return a string representation of this query.
*/
toString(options?: SerializationOptions): string;
/**
* Return `true` if this query is a _singular query_, or `false` otherwise.
*/
singularQuery(): boolean;
}