jGrep

A command-line utility for searching and filtering JSON files, with optional dot-separated path queries.


Implement core functionality: search for specific keys or values in a single JSON file.

  • Load a JSON file and validate its structure
  • Search for a key or value, printing matching entries with full path (e.g., user.name)
  • Handle invalid JSON, missing file, or key not found errors

Functional result: jgrep.py "name" file.json prints all keys or values matching "name" along with their JSON path.


Phase 2 — Recursive Search & Multiple Files

Extend to handle multiple JSON files and folders.

  • Traverse directories recursively
  • Process .json files only
  • Support searching across multiple files
  • Optional case-insensitive matching (-ignoreCase)

Functional result: jgrep.py "admin" ./configs -ignoreCase lists all matches across JSON files in the folder tree.


Phase 3 — JSONPath-Style Queries & Filtering

Add lightweight JSONPath-style dot-separated querying and simple filtering.

  • Support dot-separated paths for nested access (e.g., user.address.city)
  • Allow numeric array indexing (orders.items.0.name)
  • Keep it simple — no wildcards, slicing, or complex expressions
  • Combine with recursive search and ignore-case options

Functional result: jgrep.py "orders.items.0.product" data/ finds the first product in every order, recursively.


Phase 4 — Counting, Excluding & CLI Polishing

Finalize the tool with filtering options, formatted output, and robust CLI.

  • Implement -not option to show non-matching entries
  • Implement -count option to count matches per file
  • Use argparse to support multiple files/folders and query types
  • Format output for clarity (e.g., JSON path + value)
  • Add README with usage examples and basic error logging

Functional result: jgrep.py "user.role" ./configs -ignoreCase -count -not counts non-admin roles and reports them clearly.