/** * JSONPath parsing utilities. * * Supports a subset of JSONPath syntax for accessing nested values: * - Dot notation: "foo.bar.baz" * - Bracket notation: "foo['bar']" or "foo[\"bar\"]" * - Array indices: "items[0]" or "items['0']" * - Mixed: "foo.items[0].bar" * - Escaped characters: "foo['bar.baz']" for keys containing dots * - Special characters: "foo['key with spaces']" or "foo['key\"with\"quotes']" */ /** * Token types for JSONPath parsing. */ type TokenType = 'property' | 'index' | 'bracket_property'; /** * A parsed path segment. */ interface PathSegment { type: TokenType; value: string | number; } /** * Result of parsing a JSONPath expression. */ export interface ParseResult { segments: PathSegment[]; error?: string; } /** * Parse a JSONPath expression into segments. * * @param path - The JSONPath expression to parse * @returns ParseResult with segments or error */ export declare function parsePath(path: string): ParseResult; /** * Get a value from an object using a parsed path. * * @param obj - The object to access * @param segments - The parsed path segments * @returns The value at the path, or undefined if not found */ export declare function getValueBySegments(obj: unknown, segments: PathSegment[]): unknown; /** * Get a value from an object using a JSONPath expression. * * This is the main API function combining parsing and value retrieval. * * @param obj - The object to access * @param path - The JSONPath expression * @returns The value at the path, or undefined if not found or path is invalid * * @example * // Simple paths * getValueAtPath({ a: { b: 1 } }, 'a.b') // => 1 * * @example * // Array access * getValueAtPath({ items: [1, 2, 3] }, 'items[1]') // => 2 * * @example * // Keys with dots * getValueAtPath({ 'key.with.dots': 42 }, "['key.with.dots']") // => 42 * * @example * // Keys with spaces * getValueAtPath({ 'my key': 'value' }, "['my key']") // => 'value' */ export declare function getValueAtPath(obj: unknown, path: string): unknown; /** * Check if a path is valid JSONPath syntax. * * @param path - The path to validate * @returns True if the path is valid, false otherwise */ export declare function isValidPath(path: string): boolean; /** * Convert a JSONPath expression to a normalized form. * Useful for comparing paths that may use different notations. * * @param path - The path to normalize * @returns Normalized path string, or the original if parsing fails */ export declare function normalizePath(path: string): string; export {}; //# sourceMappingURL=jsonpath.d.ts.map