json-p3 1.3.5 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { FilterExpression } from "./expression";
2
2
  import { FilterFunction } from "./functions/function";
3
3
  import { JSONPathNode, JSONPathNodeList } from "./node";
4
- import { JSONPath } from "./path";
4
+ import { JSONPathQuery } from "./path";
5
5
  import { Token } from "./token";
6
6
  import { JSONValue } from "../types";
7
7
  /**
@@ -99,9 +99,9 @@ export declare class JSONPathEnvironment {
99
99
  constructor(options?: JSONPathEnvironmentOptions);
100
100
  /**
101
101
  * @param path - A JSONPath query to parse.
102
- * @returns A new {@link JSONPath} object, bound to this environment.
102
+ * @returns A new {@link JSONPathQuery} object, bound to this environment.
103
103
  */
104
- compile(path: string): JSONPath;
104
+ compile(path: string): JSONPathQuery;
105
105
  /**
106
106
  *
107
107
  * @param path - A JSONPath query to parse and evaluate against _value_.
@@ -138,7 +138,7 @@ export declare class JSONPathEnvironment {
138
138
  /**
139
139
  * Check the well-typedness of a function's arguments at compile-time.
140
140
  *
141
- * This method is called by the {@link Parser} when parsing function calls.
141
+ * This method is called by the parser when parsing function calls.
142
142
  * It is expected to throw a {@link JSONPathTypeError} if the function's
143
143
  * parameters are not well-typed.
144
144
  *
@@ -1,7 +1,7 @@
1
1
  import { JSONPathNodeList } from "./node";
2
- import { JSONPath } from "./path";
2
+ import { JSONPathQuery } from "./path";
3
3
  import { Token } from "./token";
4
- import { FilterContext } from "./types";
4
+ import { FilterContext, SerializationOptions } from "./types";
5
5
  /**
6
6
  * Base class for all filter expressions.
7
7
  */
@@ -16,7 +16,7 @@ export declare abstract class FilterExpression {
16
16
  /**
17
17
  * Return a string representation of the expression.
18
18
  */
19
- abstract toString(): string;
19
+ abstract toString(options?: SerializationOptions): string;
20
20
  }
21
21
  /**
22
22
  * Base class for JSONPath ValueType literals.
@@ -54,7 +54,7 @@ export declare class PrefixExpression extends FilterExpression {
54
54
  readonly right: FilterExpression;
55
55
  constructor(token: Token, operator: string, right: FilterExpression);
56
56
  evaluate(context: FilterContext): boolean;
57
- toString(): string;
57
+ toString(options?: SerializationOptions): string;
58
58
  }
59
59
  export declare class InfixExpression extends FilterExpression {
60
60
  readonly token: Token;
@@ -64,30 +64,30 @@ export declare class InfixExpression extends FilterExpression {
64
64
  readonly logical: boolean;
65
65
  constructor(token: Token, left: FilterExpression, operator: string, right: FilterExpression);
66
66
  evaluate(context: FilterContext): boolean;
67
- toString(): string;
67
+ toString(options?: SerializationOptions): string;
68
68
  }
69
69
  export declare class LogicalExpression extends FilterExpression {
70
70
  readonly token: Token;
71
71
  readonly expression: FilterExpression;
72
72
  constructor(token: Token, expression: FilterExpression);
73
73
  evaluate(context: FilterContext): boolean;
74
- toString(): string;
74
+ toString(options?: SerializationOptions): string;
75
75
  }
76
76
  /**
77
77
  * Base class for relative and absolute JSONPath query expressions.
78
78
  */
79
- export declare abstract class JSONPathQuery extends FilterExpression {
79
+ export declare abstract class FilterQuery extends FilterExpression {
80
80
  readonly token: Token;
81
- readonly path: JSONPath;
82
- constructor(token: Token, path: JSONPath);
81
+ readonly path: JSONPathQuery;
82
+ constructor(token: Token, path: JSONPathQuery);
83
83
  }
84
- export declare class RelativeQuery extends JSONPathQuery {
84
+ export declare class RelativeQuery extends FilterQuery {
85
85
  evaluate(context: FilterContext): JSONPathNodeList;
86
- toString(): string;
86
+ toString(options?: SerializationOptions): string;
87
87
  }
88
- export declare class RootQuery extends JSONPathQuery {
88
+ export declare class RootQuery extends FilterQuery {
89
89
  evaluate(context: FilterContext): JSONPathNodeList;
90
- toString(): string;
90
+ toString(options?: SerializationOptions): string;
91
91
  }
92
92
  export declare class FunctionExtension extends FilterExpression {
93
93
  readonly token: Token;
@@ -95,7 +95,7 @@ export declare class FunctionExtension extends FilterExpression {
95
95
  readonly args: FilterExpression[];
96
96
  constructor(token: Token, name: string, args: FilterExpression[]);
97
97
  evaluate(context: FilterContext): unknown;
98
- toString(): string;
98
+ toString(options?: SerializationOptions): string;
99
99
  private unpack_node_list;
100
100
  }
101
101
  export declare function compare(left: unknown, operator: string, right: unknown): boolean;
@@ -3,15 +3,15 @@ import { LogicalExpression } from "../expression";
3
3
  import { JSONPathNode } from "../node";
4
4
  import { JSONPathSelector } from "../selectors";
5
5
  import { Token } from "../token";
6
+ import { type SerializationOptions } from "../types";
6
7
  export declare class KeySelector extends JSONPathSelector {
7
8
  readonly environment: JSONPathEnvironment;
8
9
  readonly token: Token;
9
10
  readonly key: string;
10
- readonly shorthand: boolean;
11
- constructor(environment: JSONPathEnvironment, token: Token, key: string, shorthand?: boolean);
12
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
13
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
14
- toString(): string;
11
+ constructor(environment: JSONPathEnvironment, token: Token, key: string);
12
+ resolve(node: JSONPathNode): JSONPathNode[];
13
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
14
+ toString(options?: SerializationOptions): string;
15
15
  }
16
16
  /**
17
17
  * Object property name selector or array index selector.
@@ -19,10 +19,9 @@ export declare class KeySelector extends JSONPathSelector {
19
19
  export declare class KeysSelector extends JSONPathSelector {
20
20
  readonly environment: JSONPathEnvironment;
21
21
  readonly token: Token;
22
- readonly shorthand: boolean;
23
- constructor(environment: JSONPathEnvironment, token: Token, shorthand?: boolean);
24
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
25
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
22
+ constructor(environment: JSONPathEnvironment, token: Token);
23
+ resolve(node: JSONPathNode): JSONPathNode[];
24
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
26
25
  toString(): string;
27
26
  }
28
27
  export declare class KeysFilterSelector extends JSONPathSelector {
@@ -30,7 +29,7 @@ export declare class KeysFilterSelector extends JSONPathSelector {
30
29
  readonly token: Token;
31
30
  readonly expression: LogicalExpression;
32
31
  constructor(environment: JSONPathEnvironment, token: Token, expression: LogicalExpression);
33
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
34
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
35
- toString(): string;
32
+ resolve(node: JSONPathNode): JSONPathNode[];
33
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
34
+ toString(options?: SerializationOptions): string;
36
35
  }
@@ -1,10 +1,12 @@
1
1
  import { JSONValue } from "../types";
2
2
  import { JSONPathEnvironment } from "./environment";
3
3
  import { JSONPathNode, JSONPathNodeList } from "./node";
4
- import { JSONPath } from "./path";
4
+ import { JSONPathQuery } from "./path";
5
5
  export { JSONPathEnvironment } from "./environment";
6
6
  export type { JSONPathEnvironmentOptions } from "./environment";
7
- export { JSONPath } from "./path";
7
+ export { JSONPathSegment } from "./segments";
8
+ export { JSONPathSelector } from "./selectors";
9
+ export { JSONPathQuery } from "./path";
8
10
  export { JSONPathNodeList, JSONPathNode } from "./node";
9
11
  export { Token, TokenKind } from "./token";
10
12
  export * as selectors from "./selectors";
@@ -14,7 +16,7 @@ export { FunctionExpressionType } from "./functions";
14
16
  export type { FilterFunction } from "./functions";
15
17
  export { JSONPathError, JSONPathIndexError, JSONPathLexerError, JSONPathSyntaxError, JSONPathTypeError, JSONPathRecursionLimitError, } from "./errors";
16
18
  export { Nothing, KEY_MARK } from "./types";
17
- export type { JSONPathValue, FilterContext } from "./types";
19
+ export type { JSONPathValue, FilterContext, SerializationOptions, } from "./types";
18
20
  export declare const DEFAULT_ENVIRONMENT: JSONPathEnvironment;
19
21
  /**
20
22
  * Query JSON value _value_ with JSONPath expression _path_.
@@ -61,7 +63,7 @@ export declare function lazyQuery(path: string, value: JSONValue): IterableItera
61
63
  * If filter function arguments are invalid, or filter expression are
62
64
  * used in an invalid way.
63
65
  */
64
- export declare function compile(path: string): JSONPath;
66
+ export declare function compile(path: string): JSONPathQuery;
65
67
  /**
66
68
  * Return a {@link JSONPathNode} instance for the first object found in
67
69
  * _value_ matching _path_.
@@ -1,5 +1,6 @@
1
1
  import { JSONPointer } from "../pointer";
2
2
  import { JSONValue } from "../types";
3
+ import { type SerializationOptions } from "./types";
3
4
  /**
4
5
  * The pair of a JSON value and its location found in the target JSON value.
5
6
  */
@@ -13,12 +14,23 @@ export declare class JSONPathNode {
13
14
  * @param root - The target value at the top of the JSON node tree.
14
15
  */
15
16
  constructor(value: JSONValue, location: Array<string | number>, root: JSONValue);
17
+ /**
18
+ * @deprecated Use {@link getPath} with `options.form` set to `canonical` instead.
19
+ */
16
20
  get path(): string;
21
+ /**
22
+ * Get the path to this node in the target JSON value.
23
+ *
24
+ * Given that the path refers to the singular current node, the returned path
25
+ * will always be a normalized path if `options.form` is set to `canonical`,
26
+ * following section 2.7 of RFC 9535.
27
+ */
28
+ getPath(options?: SerializationOptions): string;
17
29
  /**
18
30
  * Return this node's location as a {@link JSONPointer}.
19
31
  */
20
32
  toPointer(): JSONPointer;
21
- private decode_name_location;
33
+ private decodeNameLocation;
22
34
  }
23
35
  /**
24
36
  *
@@ -59,7 +71,7 @@ export declare class JSONPathNodeList {
59
71
  * A normalized path contains only property name and index selectors, and
60
72
  * always uses bracketed segments, never shorthand selectors.
61
73
  */
62
- paths(): string[];
74
+ paths(options?: SerializationOptions): string[];
63
75
  /**
64
76
  * @returns An array of {@link JSONPointer} instances, one for each node
65
77
  * in the list.
@@ -1,6 +1,7 @@
1
1
  import { JSONPathEnvironment } from "./environment";
2
2
  import { BooleanLiteral, FilterExpression, FunctionExtension, InfixExpression, NullLiteral, NumberLiteral, PrefixExpression, RelativeQuery, RootQuery, StringLiteral } from "./expression";
3
- import { BracketedSelection, FilterSelector, IndexSelector, JSONPathSelector, SliceSelector } from "./selectors";
3
+ import { FilterSelector, IndexSelector, JSONPathSelector, SliceSelector } from "./selectors";
4
+ import { JSONPathSegment } from "./segments";
4
5
  import { Token, TokenStream } from "./token";
5
6
  import { CurrentKey } from "./extra/expression";
6
7
  /**
@@ -10,12 +11,12 @@ export declare class Parser {
10
11
  readonly environment: JSONPathEnvironment;
11
12
  protected tokenMap: Map<string, (stream: TokenStream) => FilterExpression>;
12
13
  constructor(environment: JSONPathEnvironment);
13
- parse(stream: TokenStream): JSONPathSelector[];
14
- protected parsePath(stream: TokenStream, inFilter?: boolean): JSONPathSelector[];
15
- protected parseSegment(stream: TokenStream): JSONPathSelector | null;
14
+ parse(stream: TokenStream): JSONPathSegment[];
15
+ protected parseQuery(stream: TokenStream, inFilter?: boolean): JSONPathSegment[];
16
+ protected parseSelectors(stream: TokenStream): JSONPathSelector[];
16
17
  protected parseIndex(stream: TokenStream): IndexSelector;
17
18
  protected parseSlice(stream: TokenStream): SliceSelector;
18
- protected parseBracketedSelection(stream: TokenStream): BracketedSelection;
19
+ protected parseBracketedSelection(stream: TokenStream): JSONPathSelector[];
19
20
  protected parseFilter(stream: TokenStream, keys?: boolean): FilterSelector;
20
21
  protected parseBoolean(stream: TokenStream): BooleanLiteral;
21
22
  protected parseNull(stream: TokenStream): NullLiteral;
@@ -1,29 +1,25 @@
1
1
  import { JSONPathEnvironment } from "./environment";
2
2
  import { JSONPathNode, JSONPathNodeList } from "./node";
3
- import { JSONPathSelector } from "./selectors";
4
3
  import { JSONValue } from "../types";
4
+ import { JSONPathSegment } from "./segments";
5
+ import { SerializationOptions } from "./types";
5
6
  /**
6
- *
7
+ * A compiled JSONPath query ready to be applied to different data repeatedly.
7
8
  */
8
- export declare class JSONPath {
9
+ export declare class JSONPathQuery {
9
10
  readonly environment: JSONPathEnvironment;
10
- readonly selectors: JSONPathSelector[];
11
+ readonly segments: JSONPathSegment[];
12
+ constructor(environment: JSONPathEnvironment, segments: JSONPathSegment[]);
11
13
  /**
12
- *
13
- * @param environment -
14
- * @param selectors -
15
- */
16
- constructor(environment: JSONPathEnvironment, selectors: JSONPathSelector[]);
17
- /**
18
- *
19
- * @param value -
20
- * @returns
14
+ * Apply this JSONPath query to _value_.
15
+ * @param value - A JSON-like object to apply this query to.
16
+ * @returns Nodes matched by applying this query to _value_.
21
17
  */
22
18
  query(value: JSONValue): JSONPathNodeList;
23
19
  /**
24
- *
25
- * @param value -
26
- * @returns
20
+ * Apply this JSONPath query to _value_.
21
+ * @param value - A JSON-like object to apply this query to.
22
+ * @returns An iterator over nodes matched by applying this query to _value_.
27
23
  */
28
24
  lazyQuery(value: JSONValue): IterableIterator<JSONPathNode>;
29
25
  /**
@@ -36,8 +32,11 @@ export declare class JSONPath {
36
32
  */
37
33
  match(value: JSONValue): JSONPathNode | undefined;
38
34
  /**
39
- *
35
+ * Return a string representation of this query.
36
+ */
37
+ toString(options?: SerializationOptions): string;
38
+ /**
39
+ * Return `true` if this query is a _singular query_, or `false` otherwise.
40
40
  */
41
- toString(): string;
42
41
  singularQuery(): boolean;
43
42
  }
@@ -0,0 +1,39 @@
1
+ import { JSONPathEnvironment } from "./environment";
2
+ import { JSONPathNode } from "./node";
3
+ import { JSONPathSelector } from "./selectors";
4
+ import { Token } from "./token";
5
+ import { type SerializationOptions } from "./types";
6
+ /** Base class for all JSONPath segments. Both shorthand and bracketed. */
7
+ export declare abstract class JSONPathSegment {
8
+ readonly environment: JSONPathEnvironment;
9
+ readonly token: Token;
10
+ readonly selectors: JSONPathSelector[];
11
+ constructor(environment: JSONPathEnvironment, token: Token, selectors: JSONPathSelector[]);
12
+ /**
13
+ * @param nodes - Nodes matched by preceding segments.
14
+ */
15
+ abstract resolve(nodes: JSONPathNode[]): JSONPathNode[];
16
+ /**
17
+ * @param nodes - Nodes matched by preceding segments.
18
+ */
19
+ abstract lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
20
+ /**
21
+ * Return a string representation of this segment.
22
+ */
23
+ abstract toString(options?: SerializationOptions): string;
24
+ }
25
+ /** The child selection segment. */
26
+ export declare class ChildSegment extends JSONPathSegment {
27
+ resolve(nodes: JSONPathNode[]): JSONPathNode[];
28
+ lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
29
+ toString(options?: SerializationOptions): string;
30
+ }
31
+ /** The recursive descent segment. */
32
+ export declare class DescendantSegment extends JSONPathSegment {
33
+ resolve(nodes: JSONPathNode[]): JSONPathNode[];
34
+ lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
35
+ toString(options?: SerializationOptions): string;
36
+ private visit;
37
+ private nondeterministicVisit;
38
+ private nondeterministicChildren;
39
+ }
@@ -2,6 +2,7 @@ import { JSONPathEnvironment } from "./environment";
2
2
  import { LogicalExpression } from "./expression";
3
3
  import { JSONPathNode } from "./node";
4
4
  import { Token } from "./token";
5
+ import { type SerializationOptions } from "./types";
5
6
  /**
6
7
  * Base class for all JSONPath segments and selectors.
7
8
  */
@@ -13,17 +14,17 @@ export declare abstract class JSONPathSelector {
13
14
  */
14
15
  constructor(environment: JSONPathEnvironment, token: Token);
15
16
  /**
16
- * @param nodes - Nodes matched by preceding selectors.
17
+ * @param node - Nodes matched by preceding selectors.
17
18
  */
18
- abstract resolve(nodes: JSONPathNode[]): JSONPathNode[];
19
+ abstract resolve(node: JSONPathNode): JSONPathNode[];
19
20
  /**
20
- * @param nodes - Nodes matched by preceding selectors.
21
+ * @param node - Nodes matched by preceding selectors.
21
22
  */
22
- abstract lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
23
+ abstract lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
23
24
  /**
24
25
  * Return a canonical string representation of this selector.
25
26
  */
26
- abstract toString(): string;
27
+ abstract toString(options?: SerializationOptions): string;
27
28
  }
28
29
  /**
29
30
  * Shorthand and quoted name selector.
@@ -32,11 +33,11 @@ export declare class NameSelector extends JSONPathSelector {
32
33
  readonly environment: JSONPathEnvironment;
33
34
  readonly token: Token;
34
35
  readonly name: string;
35
- readonly shorthand: boolean;
36
- constructor(environment: JSONPathEnvironment, token: Token, name: string, shorthand: boolean);
37
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
38
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
39
- toString(): string;
36
+ constructor(environment: JSONPathEnvironment, token: Token, name: string);
37
+ resolve(node: JSONPathNode): JSONPathNode[];
38
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
39
+ toString(options?: SerializationOptions): string;
40
+ shorthand(): string | null;
40
41
  }
41
42
  /**
42
43
  * Array index selector.
@@ -46,8 +47,8 @@ export declare class IndexSelector extends JSONPathSelector {
46
47
  readonly token: Token;
47
48
  readonly index: number;
48
49
  constructor(environment: JSONPathEnvironment, token: Token, index: number);
49
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
50
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
50
+ resolve(node: JSONPathNode): JSONPathNode[];
51
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
51
52
  toString(): string;
52
53
  private normalizedIndex;
53
54
  }
@@ -58,8 +59,8 @@ export declare class SliceSelector extends JSONPathSelector {
58
59
  readonly stop?: number | undefined;
59
60
  readonly step?: number | undefined;
60
61
  constructor(environment: JSONPathEnvironment, token: Token, start?: number | undefined, stop?: number | undefined, step?: number | undefined);
61
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
62
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
62
+ resolve(node: JSONPathNode): JSONPathNode[];
63
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
63
64
  toString(): string;
64
65
  private checkRange;
65
66
  private slice;
@@ -68,41 +69,17 @@ export declare class SliceSelector extends JSONPathSelector {
68
69
  export declare class WildcardSelector extends JSONPathSelector {
69
70
  readonly environment: JSONPathEnvironment;
70
71
  readonly token: Token;
71
- readonly shorthand: boolean;
72
- constructor(environment: JSONPathEnvironment, token: Token, shorthand?: boolean);
73
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
74
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
75
- toString(): string;
76
- }
77
- export declare class RecursiveDescentSegment extends JSONPathSelector {
78
- readonly environment: JSONPathEnvironment;
79
- readonly token: Token;
80
- readonly selector: JSONPathSelector;
81
- constructor(environment: JSONPathEnvironment, token: Token, selector: JSONPathSelector);
82
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
83
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
84
- protected _lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
72
+ constructor(environment: JSONPathEnvironment, token: Token);
73
+ resolve(node: JSONPathNode): JSONPathNode[];
74
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
85
75
  toString(): string;
86
- private visitor;
87
- protected nondeterministicVisitor(root: JSONPathNode, depth?: number): JSONPathNode[];
88
- protected nondeterministicChildren(node: JSONPathNode): JSONPathNode[];
89
76
  }
90
77
  export declare class FilterSelector extends JSONPathSelector {
91
78
  readonly environment: JSONPathEnvironment;
92
79
  readonly token: Token;
93
80
  readonly expression: LogicalExpression;
94
81
  constructor(environment: JSONPathEnvironment, token: Token, expression: LogicalExpression);
95
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
96
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
97
- toString(): string;
98
- }
99
- export type BracketedSegment = FilterSelector | IndexSelector | NameSelector | SliceSelector | WildcardSelector;
100
- export declare class BracketedSelection extends JSONPathSelector {
101
- readonly environment: JSONPathEnvironment;
102
- readonly token: Token;
103
- readonly items: BracketedSegment[];
104
- constructor(environment: JSONPathEnvironment, token: Token, items: BracketedSegment[]);
105
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
106
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
107
- toString(): string;
82
+ resolve(node: JSONPathNode): JSONPathNode[];
83
+ lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
84
+ toString(options?: SerializationOptions): string;
108
85
  }
@@ -0,0 +1,6 @@
1
+ /** Usable in a quoted path. */
2
+ export declare function toQuoted(name: string): string;
3
+ /** Usable in a normalized path. */
4
+ export declare function toCanonical(name: string): string;
5
+ /** Usable in a shorthand path. */
6
+ export declare function toShorthand(name: string): string | null;
@@ -6,7 +6,7 @@ export declare const Nothing: unique symbol;
6
6
  */
7
7
  export type JSONPathValue = JSONValue | typeof Nothing;
8
8
  /**
9
- * Object passed to FilterExpression.evaluate().
9
+ * Object passed to `FilterExpression.evaluate()`.
10
10
  */
11
11
  export type FilterContext = {
12
12
  environment: JSONPathEnvironment;
@@ -22,3 +22,25 @@ export declare function hasStringKey(value: unknown, key: string): value is {
22
22
  [key: string]: unknown;
23
23
  };
24
24
  export declare const KEY_MARK = "\u0002";
25
+ /**
26
+ * Options for serializing paths.
27
+ */
28
+ export type SerializationOptions = {
29
+ /**
30
+ * `pretty` paths always use:
31
+ * - shorthand notation rather than dot notation where possible
32
+ * - double quotes rather than single quotes for string literals and where shorthand
33
+ * notation is not possible
34
+ * - short escape sequences for common non-printing characters such as `\n` and `\t`
35
+ *
36
+ * `canonical` paths always use:
37
+ * - bracket notation for name and wildcard selectors
38
+ * - single quotes for name selectors and string literals
39
+ * - short escape sequences for common non-printing characters such as `\n` and `\t`
40
+ *
41
+ * `canonical` paths will produce a normalized path where available, but cannot be
42
+ * considered normalized paths if the query does not represent a singular, absolute node.
43
+ */
44
+ form: "pretty" | "canonical";
45
+ };
46
+ export declare const defaultSerializationOptions: SerializationOptions;