Crates.io | json-grep |
lib.rs | json-grep |
version | 0.1.0 |
created_at | 2025-07-25 03:39:17.820278+00 |
updated_at | 2025-07-25 03:39:17.820278+00 |
description | A grep-like utility for searching JSON data with regular expressions |
homepage | |
repository | https://gitlab.com/cky/json-grep |
max_upload_size | |
id | 1767154 |
size | 23,805 |
json-grep is a fairly minimal grep-style utility for searching JSON data for a given regular expression.
The original intent is to identify where in the JSON input matches are found. I needed this because, having lost my sight in 2024, it had become impractical for me to use indentation to determine the tree location of the strings I was searching for—in particular, line-based locations like in standard grep are decidedly unuseful.
json-grep was also a way for me to learn serde's streaming API. Everything in json-grep is handled in a streaming way, allowing very large JSON input to be processed. (In theory—currently it loads the whole input into memory, but a future improvement seeks to use mmap
for regular files and buffered reads for piped data.)
Despite paths being printed in JSONPath notation (since there's no point in reinventing a path notation), there are no plans to support JSONPath queries. This is because JSONPath queries require an actual JSON object tree to be built, and that's fundamentally opposite to the streaming approach: think of DOM vs SAX APIs but for JSON. I could theoretically support a subset of JSONPath queries that only handled name, index, and wildcard segments, without any support for extensions (or even negative indices for that matter), but then that wouldn't really be JSONPath, would it?