jq-lite 0.1.5

A lightweight CLI tool for querying JSON using dot notation
jq-lite-0.1.5 is not a library.

๐Ÿ“ฆ 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_json for parsing

๐Ÿ“– Usage

jq-lite <query> <file-path>

๐Ÿงช Examples

  • Basic query
jq-lite "name" data.json
  • Nested query
jq-lite "user.name" data.json
  • Multiple queries
jq-lite "name age user.email" data.json

๐Ÿ› ๏ธ How It Works

  • Queries are split by whitespace
  • Nested queries (user.name) are converted into JSON Pointer format:
user.name โ†’ /user/name

Uses

  • Value::get() for top-level fields
  • Value::pointer() for nested access

โš ๏ธ Current Limitations

  • โŒ Not streaming (loads full JSON into memory)

Recent Addons

  1. Add stdin support for JSON input

    Allow piping JSON into jq-lite:

    cat data.json | jq-lite "name"
    
  2. Support raw JSON string as input

    Allow users to pass JSON directly instead of file path:

    jq-lite "name" '{"name":"John"}'
    
  3. Improve CLI argument validation

    • Handle missing arguments
    • Show usage instructions
    • Prevent panics on missing inputs
  4. Add --help flag

    Display usage, examples, and available options

  5. Support array indexing in queries

    jq-lite "users[0].name" data.json
    
  6. Support wildcard array queries

    jq-lite "users[].name" data.json
    
  7. Refactor query parsing logic Replace simple .split(".") with a proper parser to support:

    • Arrays
    • Future filters
    • Better extensibility
  8. Validate query syntax before execution

    Return meaningful errors for invalid queries

  9. Add --pretty flag for formatted output

    Pretty-print JSON results

  10. Add --compact flag

    Return minified JSON output

  11. Add --raw flag

    Print raw values without JSON quotes

  12. Improve error handling and messaging

    • File not found
    • Invalid JSON
    • Missing fields
    • Invalid queries
  13. Add strict mode for query failures

    • Fail when a query returns no result
    • Return non-zero exit code
  14. Add unit tests

  • Nested queries
  • Missing fields
  • Invalid JSON
  1. Add CLI integration tests

    Test full command execution

๐Ÿ’ก Future Enhancements (Stretch Goals)

  1. Implement query AST (Abstract Syntax Tree)

    Example:

    users[0].name โ†’ Field("users") โ†’ Index(0) โ†’ Field("name")
    
  2. Add streaming JSON parsing

    Handle large JSON files without loading entire file into memory

  3. Support pipe operator (|)

jq-lite "users | name" data.json
  1. Add simple filtering support
jq-lite "users[?age>18]" data.json
  1. Add interactive REPL mode
jq-lite
> user.name

๐Ÿ—๏ธ Building

cargo build --release

๐Ÿ“„ License

MIT

๐Ÿค Contributing

Contributions are welcome. Please open an issue before submitting a PR.