jq-lite 0.1.5

A lightweight CLI tool for querying JSON using dot notation
# ๐Ÿ“ฆ 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

```bash
jq-lite <query> <file-path>
```

## ๐Ÿงช Examples

- Basic query

```bash
jq-lite "name" data.json
```

- Nested query

```bash
jq-lite "user.name" data.json
```

- Multiple queries

```bash
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:

```bash
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:

   ```bash
   cat data.json | jq-lite "name"
   ```

2. **Support raw JSON string as input**

   Allow users to pass JSON directly instead of file path:

   ```bash
   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**

   ```bash
   jq-lite "users[0].name" data.json
   ```

6. **Support wildcard array queries**

   ```bash
   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

15. **Add CLI integration tests**

    Test full command execution

## ๐Ÿ’ก Future Enhancements (Stretch Goals)

16. **Implement query AST (Abstract Syntax Tree)**

    Example:

    ```bash
    users[0].name โ†’ Field("users") โ†’ Index(0) โ†’ Field("name")
    ```

17. **Add streaming JSON parsing**

    Handle large JSON files without loading entire file into memory

18. **Support pipe operator (|)**

```bash
jq-lite "users | name" data.json
```

19. **Add simple filtering support**

```bash
jq-lite "users[?age>18]" data.json
```

20. **Add interactive REPL mode**

```bash
jq-lite
> user.name
```

## ๐Ÿ—๏ธ Building

```bash
cargo build --release
```

## ๐Ÿ“„ License

MIT

## ๐Ÿค Contributing

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