| Crates.io | rjx |
| lib.rs | rjx |
| version | 0.1.1 |
| created_at | 2025-10-05 00:27:01.786535+00 |
| updated_at | 2025-10-05 00:42:22.69449+00 |
| description | A fast and lightweight JSON processor and query tool in Rust |
| homepage | https://github.com/abhinavcdev/rjx |
| repository | https://github.com/abhinavcdev/rjx |
| max_upload_size | |
| id | 1868481 |
| size | 1,923,556 |
RJX is a high-performance alternative to jq written in Rust, designed for processing JSON data with exceptional speed and minimal resource consumption. It provides a familiar query language for filtering, transforming, and manipulating JSON data while delivering significant performance improvements over traditional tools.
Benchmarks against real-world data show that RJX consistently outperforms jq:
| Query Type | Speed Improvement |
|---|---|
| Simple property access | 4-7x faster |
| Nested property access | 4-5x faster |
| Array indexing | 5-7x faster |
| Array iteration | 4-5x faster |
| Object operations | 4-6x faster |
These improvements are particularly noticeable when processing large JSON files like Terraform state files or API responses.
.field or ."field name with spaces".[0] for indexing, .[1:3] for slicing, .[] for iteration|) for chaining operationsselect(.field == "value") for conditional filtering{key1, key2} or arrays [expr1, expr2]length, keys, map() for data transformationcargo install rjx
# Clone the repository
git clone https://github.com/abhinavcdev/rjx.git
cd rjx
# Build the project
cargo build --release
# The binary will be available at target/release/rjx
# You can copy it to a directory in your PATH
cp target/release/rjx ~/.local/bin/ # Linux/macOS
rjx [OPTIONS] -q <QUERY> [FILE]
| Option | Description |
|---|---|
-q, --query <QUERY> |
The query to run on the JSON input |
-p, --pretty |
Pretty print the output |
-c, --compact |
Compact output (no whitespace) |
-r, --raw |
Raw output (unwrap string values) |
-C, --color |
Colorize the output |
-b, --benchmark |
Show execution time |
--debug |
Show detailed error information |
RJX can read JSON from files or stdin:
# From a file
rjx -q '.name' input.json
# From stdin
cat input.json | rjx -q '.name'
curl -s 'https://api.example.com/data' | rjx -q '.results[]'
# Access properties
rjx -q '.name' input.json
rjx -q '.address.city' input.json
# Array operations
rjx -q '.users[0]' input.json # First element
rjx -q '.users[1:3]' input.json # Slice (elements 1 and 2)
rjx -q '.users[]' input.json # All elements
# Filtering
rjx -q '.users[] | select(.active == true)' input.json
rjx -q '.items[] | select(.price > 100)' input.json
# Transformations
rjx -q '.address | {city, state}' input.json
rjx -q '.users[] | {name, email}' input.json
# Metadata
rjx -q '.items | length' input.json
rjx -q '.config | keys' input.json
RJX includes built-in benchmarking capabilities to measure performance:
# Show execution time for a query
rjx -q '.users[] | select(.active)' -b large-file.json
For comprehensive benchmarks against jq, use the included benchmark script:
# Run comparative benchmarks (requires hyperfine and jq)
./benches/sample-benchmarks/run_benchmarks.sh
The following results were obtained on a Terraform state file (~700KB):
| Query | RJX | jq | Speedup |
|---|---|---|---|
.version |
2.9ms | 19.9ms | 6.8x |
.resources[0].type |
3.7ms | 18.7ms | 5.1x |
| `.resources[] | select(.type == "aws_instance")` | 4.4ms | 19.8ms |
| `.resources | length` | 2.8ms | 19.9ms |
RJX is under active development and doesn't yet support all jq features:
map_values, to_entries)Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)See the CONTRIBUTING.md file for more details.
This project is licensed under the MIT License - see the LICENSE file for details.
RJX supports a query language similar to jq with the following operators and expressions:
. - Identity (returns the input unchanged).field - Access a field in an object."field name" - Access a field with spaces or special characters.[0] - Access an array element by index.[1:3] - Array slice (from index 1 up to but not including 3).. - Recursive descent (find all nested values).[] - Array iteration (iterate over all elements)| - Pipe operator (chain operations)select(...) - Filter elements based on a condition{field1, field2} - Create an object with specified fields[expr1, expr2] - Create an array with results of expressionslength - Get length of array, object, or stringkeys - Get keys of an object or indices of an arraymap(expr) - Apply expression to each element