UNPKG

json-p3

Version:

JSONPath, JSON Pointer and JSON Patch

77 lines (76 loc) 3.33 kB
import { JSONValue } from "../types"; import { JSONPathEnvironment } from "./environment"; import { JSONPathNode, JSONPathNodeList } from "./node"; import { JSONPathQuery } from "./path"; export { JSONPathEnvironment } from "./environment"; export type { JSONPathEnvironmentOptions } from "./environment"; export { JSONPathSegment } from "./segments"; export { JSONPathSelector } from "./selectors"; export { JSONPathQuery } from "./path"; export { JSONPathNodeList, JSONPathNode } from "./node"; export { Token, TokenKind } from "./token"; export * as selectors from "./selectors"; export * as expressions from "./expression"; export * as functions from "./functions"; export { FunctionExpressionType } from "./functions"; export type { FilterFunction } from "./functions"; export { JSONPathError, JSONPathIndexError, JSONPathLexerError, JSONPathSyntaxError, JSONPathTypeError, JSONPathRecursionLimitError, } from "./errors"; export { Nothing, KEY_MARK } from "./types"; export type { JSONPathValue, FilterContext, SerializationOptions, } from "./types"; export declare const DEFAULT_ENVIRONMENT: JSONPathEnvironment; /** * Query JSON value _value_ with JSONPath expression _path_. * @param path - A JSONPath expression/query. * @param value - The JSON-like value the JSONPath query is applied to. * @returns A list of JSONPathNode objects, one for each value matched * by _path_ in _value_. * * @throws {@link JSONPathSyntaxError} * If the path does not conform to standard syntax. * * @throws {@link JSONPathTypeError} * If filter function arguments are invalid, or filter expression are * used in an invalid way. */ export declare function query(path: string, value: JSONValue): JSONPathNodeList; /** * 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. * * @param path - A JSONPath expression/query. * @param value - The JSON-like value the JSONPath query is applied to. * @returns A sequence of {@link JSONPathNode} objects resulting from * applying _path_ to _value_. * * @throws {@link JSONPathSyntaxError} * If the path does not conform to standard syntax. * * @throws {@link JSONPathTypeError} * If filter function arguments are invalid, or filter expression are * used in an invalid way. */ export declare function lazyQuery(path: string, value: JSONValue): IterableIterator<JSONPathNode>; /** * Compile JSONPath _path_ for later use. * @param path - A JSONPath expression/query. * @returns A path object with a `query()` method. * * @throws {@link JSONPathSyntaxError} * If the path does not conform to standard syntax. * * @throws {@link JSONPathTypeError} * If filter function arguments are invalid, or filter expression are * used in an invalid way. */ export declare function compile(path: string): JSONPathQuery; /** * Return a {@link JSONPathNode} instance for the first object found in * _value_ matching _path_. * * @param path - A JSONPath query. * @param value - JSON-like data to which the query _path_ will be applied. * @returns The first node in _value_ matching _path_, or `undefined` if * there are no matches. */ export declare function match(path: string, value: JSONValue): JSONPathNode | undefined;