๐ฆ jq-lite
A lightweight CLI tool built in Rust for querying JSON data using simple dot notation.
๐ Current Features
- โ Read JSON from a file
- โ Query top-level fields
- โ Query nested JSON using dot notation
- โ Multiple queries in a single command (space-separated)
- โ
Uses
serde_jsonfor parsing
๐ Usage
๐งช Examples
- Basic query
- Nested query
- Multiple queries
๐ ๏ธ How It Works
- Queries are split by whitespace
- Nested queries (user.name) are converted into JSON Pointer format:
Uses
Value::get()for top-level fieldsValue::pointer()for nested access
โ ๏ธ Current Limitations
- โ Not streaming (loads full JSON into memory)
Recent Addons
-
Add stdin support for JSON input
Allow piping JSON into jq-lite:
| -
Support raw JSON string as input
Allow users to pass JSON directly instead of file path:
-
Improve CLI argument validation
- Handle missing arguments
- Show usage instructions
- Prevent panics on missing inputs
-
Add
--helpflagDisplay usage, examples, and available options
-
Support array indexing in queries
-
Support wildcard array queries
-
Refactor query parsing logic Replace simple
.split(".")with a proper parser to support:- Arrays
- Future filters
- Better extensibility
-
Validate query syntax before execution
Return meaningful errors for invalid queries
-
Add
--prettyflag for formatted outputPretty-print JSON results
-
Add
--compactflagReturn minified JSON output
-
Add
--rawflagPrint raw values without JSON quotes
-
Improve error handling and messaging
- File not found
- Invalid JSON
- Missing fields
- Invalid queries
-
Add strict mode for query failures
- Fail when a query returns no result
- Return non-zero exit code
-
Add unit tests
- Nested queries
- Missing fields
- Invalid JSON
-
Add CLI integration tests
Test full command execution
๐ก Future Enhancements (Stretch Goals)
-
Implement query AST (Abstract Syntax Tree)
Example:
) ) ) -
Add streaming JSON parsing
Handle large JSON files without loading entire file into memory
-
Support pipe operator (|)
- Add simple filtering support
- Add interactive REPL mode
> user.name
๐๏ธ Building
๐ License
MIT
๐ค Contributing
Contributions are welcome. Please open an issue before submitting a PR.