1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! jq-like query expressions for JSON navigation.
//!
//! This module provides a subset of jq syntax for querying JSON documents
//! using the fast cursor-based navigation provided by the JSON semi-indexing.
//!
//! # Supported Syntax
//!
//! | Expression | Meaning |
//! |------------|---------|
//! | `.` | Identity (return the whole document) |
//! | `.foo` | Access field "foo" of an object |
//! | `.[0]` | Access first element of an array |
//! | `.[-1]` | Access last element of an array |
//! | `.[]` | Iterate all elements of array/object |
//! | `.[2:5]` | Slice array from index 2 to 5 |
//! | `.foo.bar` | Chained field access |
//! | `.foo[0].bar` | Mixed field and index access |
//! | `.foo?` | Optional access (null if missing) |
//! | `.foo, .bar` | Comma - output from both expressions |
//! | `[.foo, .bar]` | Array construction |
//! | `{foo: .bar}` | Object construction |
//! | `(.foo)` | Parentheses for grouping |
//! | `..` | Recursive descent |
//! | `null`, `true`, `false` | Literal values |
//! | `"string"` | String literal |
//! | `123`, `3.14` | Number literal |
//! | `.a + .b` | Arithmetic (+, -, *, /, %) |
//! | `.a == .b` | Comparison (==, !=, <, <=, >, >=) |
//! | `.a and .b` | Boolean AND |
//! | `.a or .b` | Boolean OR |
//! | `not` | Boolean NOT |
//! | `.a // .b` | Alternative (default if falsy) |
//! | `if .a then .b else .c end` | Conditional |
//! | `try .a catch .b` | Error handling |
//! | `error("msg")` | Raise error |
//! | `.a = value` | Simple assignment |
//! | `.a \|= filter` | Update assignment |
//! | `.a += value` | Compound assignment (+=, -=, *=, /=, %=) |
//! | `.a //= value` | Alternative assignment (set if null/false) |
//! | `del(.a)` | Delete field/element |
//!
//! # Example
//!
//! ```
//! use succinctly::jq::{parse, eval, JqSemantics, QueryResult};
//! use succinctly::json::{JsonIndex, StandardJson};
//!
//! let json = br#"{"users": [{"name": "Alice"}, {"name": "Bob"}]}"#;
//! let index = JsonIndex::build(json);
//! let cursor = index.root(json);
//!
//! // Get first user's name
//! let expr = parse(".users[0].name").unwrap();
//! match eval::<Vec<u64>, JqSemantics>(&expr, cursor) {
//! QueryResult::One(StandardJson::String(s)) => {
//! assert_eq!(s.as_str().unwrap().as_ref(), "Alice");
//! }
//! _ => panic!("unexpected result"),
//! }
//!
//! // Get all user names
//! let expr = parse(".users[].name").unwrap();
//! match eval::<Vec<u64>, JqSemantics>(&expr, cursor) {
//! QueryResult::Many(names) => {
//! assert_eq!(names.len(), 2);
//! }
//! _ => panic!("unexpected result"),
//! }
//! ```
pub use ;
pub use ;
pub use JqValue;
pub use ;
pub use ;
pub use OwnedValue;