Expand description
Jetro core — parser, compiler, and VM for the Jetro JSON query language.
§Execution path
source text
│ parse::parser::parse() → Expr AST
│ plan::physical::plan_query() → QueryPlan (physical IR)
│ exec::router::collect_*() → dispatches to:
│ StructuralIndex backend (jetro-experimental bitmap)
│ ViewPipeline backend (borrowed tape/Val navigation)
│ Pipeline backend (pull-based composed stages)
└─ VM fallback (bytecode stack machine)§Quick start
use jetro_core::Jetro;
let j = Jetro::from_bytes(br#"{"books":[{"price":12}]}"#.to_vec()).unwrap();
assert_eq!(j.collect("$.books.len()").unwrap(), serde_json::json!(1));use jetro_core::JetroEngine;
use std::io::Cursor;
let engine = JetroEngine::new();
let rows = Cursor::new(br#"{"name":"Ada"}
{"name":"Bob"}
"#);
let names = engine.collect_ndjson(rows, "name").unwrap();
assert_eq!(names, vec![serde_json::json!("Ada"), serde_json::json!("Bob")]);Match-limited NDJSON helpers evaluate a predicate per row, return the original full row for truthy matches, and stop after the requested number of matches:
use jetro_core::JetroEngine;
use std::io::Cursor;
let engine = JetroEngine::new();
let rows = Cursor::new(br#"{"id":1,"active":true}
{"id":2,"active":false}
{"id":3,"active":true}
"#);
let first_two = engine.collect_ndjson_matches(rows, "active", 2).unwrap();
assert_eq!(first_two, vec![
serde_json::json!({"id": 1, "active": true}),
serde_json::json!({"id": 3, "active": true}),
]);Modules§
- introspect
- Opt-in query introspection.
- io
- Streaming input/output adapters for query execution.
Macros§
- for_
each_ builtin - Expands
$macro!(...)once perBuiltinMethodvariant — the single source of truth for “all builtin methods” used by name lookup, registry exports, and any future cross-cutting per-method generation. Variant names match the correspondingdefs::*struct names.
Structs§
- Eval
Error - Evaluation error carrying a human-readable message. Propagated through
Result<Val, EvalError>across all execution layers. - Jetro
- Primary entry point. Holds a JSON document and evaluates expressions against
it. Lazy fields (
root_val,tape,structural_index,objvec_cache) are populated on first use so callers only pay for the representations a particular query actually needs. - Jetro
Engine - Long-lived multi-document query engine with an explicit plan cache. Use when the same process evaluates many expressions over many documents — parse/lower/compile work is amortised by this object, not hidden in thread-local state.
Enums§
- Jetro
Engine Error - Error returned by
JetroEngine::collect_bytesand similar methods that may fail during JSON parsing or during expression evaluation.