| Crates.io | jqish |
| lib.rs | jqish |
| version | 0.1.1 |
| created_at | 2025-09-22 23:18:09.491131+00 |
| updated_at | 2025-09-23 03:26:07.433265+00 |
| description | A subset of the `jq` language for working with in-memory data structures |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1850730 |
| size | 130,989 |
jq-like expression parserjqish implements a subset of the jq language for querying and transforming JSON-like data.
While the venerable jq is a command-line tool that operates on JSON text, jqish is a library that operates on data structures in your program. Think of it like an alternative to JSONPath or JSON Pointer.
🚧 This project is still under development. There's a grammar and parser, but no evaluator yet.
Add jqish to your project's Cargo.toml:
[dependencies]
jqish = "0.1"
use jqish::{parse, Expr};
// Parse a simple object property access.
let expr = parse(".name").unwrap();
println!("{:?}", expr); // Expr::Index(...)
// Parse an expression that constructs an object.
let expr = parse("{name, age: .user.age, active}").unwrap();
println!("{:?}", expr); // Expr::Object([...])
// Parse a more complex expression.
let expr = parse("not (.foo | .bar // .baz)").unwrap();
println!("{:?}", expr); // Expr::Not(...)
These features parse as described in the jq manual.
| Identity | . |
| Object identifier-indexing | .foo, .foo.bar, ."foo-bar" |
| Array and object indexing | .[0], .["key"], .[.expr] |
| Array slicing | .[1:3], .[2:], .[:5], .[:], .[-3], .[length() % 2] |
| Optionals | .foo?, ."foo-bar".baz?, .[1]? |
| Numbers | 42, -10, 3.14, -1e10, 1.5e-3 |
| Strings | "hello", 'good-bye', "with \"escapes\"" |
| Literals | true, false, null |
| Array construction | [], [1, 2, 3], `[.a, .b, .c |
| Object construction | {}, {hello: "world"}, {name: .user, age, "favorite-name": .color}, {(.key): .value, (.prefix + .suffix): .result} |
| Pipes | `.a |
| Arithmetic operations | +, -, *, /, % |
| Comparisons | ==, !=, <, >, <=, >= |
| Boolean operators | a and b, a or b, not b |
| Alternatives | a // b |
| Grouping | (. + 2) * 5 |
Because jqish is designed to be embedded in a larger Rust program, it's missing some of jq's advanced features.
.[], .foo[], .. | .a?. Since a jqish expression can only return a single result, there's no way to represent the output of an iterator, generator, or recursive descent.if-then-else, while, try-catch, and recursion. You can write more complex transformations that need these constructs in Rust.... as $ident.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}"Hello \(name)"jqish is distributed under the terms of either the MIT license or the Apache 2.0 license.
The jqish language is based on the syntax and semantics of jq, which is distributed under the MIT license.