jarq
An interactive jq-like JSON query tool with a TUI.
Should you use this instead of jq? Definitely not, this was just an experiment using a TUI and live filtering.
Usage
# Interactive TUI mode
|
|
# Non-interactive mode (like jq)
|
In interactive mode, type filter expressions and see results in real-time.
Keyboard Controls
Navigation Mode
| Key | Action |
|---|---|
i, / |
Enter filter edit mode |
j, ↓ |
Scroll down |
k, ↑ |
Scroll up |
g |
Go to top |
G |
Go to bottom |
Ctrl-D |
Page down |
Ctrl-U |
Page up |
s |
Toggle slurp mode |
r |
Toggle raw output |
o |
Toggle compact output |
y |
Copy filter as jq command |
q, Esc |
Quit |
Ctrl-H |
Show help |
Filter Edit Mode
| Key | Action |
|---|---|
Esc |
Exit filter edit mode |
Ctrl-P |
Toggle pause/resume evaluation |
Ctrl-C |
Cancel running evaluation |
Enter |
Evaluate now (when paused) |
Ctrl-S |
Toggle slurp mode |
Ctrl-R |
Toggle raw output |
Ctrl-O |
Toggle compact output |
Ctrl-Y |
Copy filter as jq command |
Ctrl-H |
Show help |
Background Evaluation
jarq evaluates filters in the background as you type. For large files, you can:
- Pause evaluation (
Ctrl-P): Stop auto-evaluation while you compose a complex filter - Cancel evaluation (
Ctrl-C): Stop a long-running evaluation and enter pause mode - Evaluate on demand (
Enter): When paused, manually trigger evaluation
When paused, the filter is still validated for syntax errors in real-time.
Filter Syntax
. # identity
.foo # field access
.foo? # optional (suppress errors)
.[0] # array index
.[-1] # negative index (from end)
.[2:5] # array slice
.[:-1] # slice (all but last)
.[] # iterate all elements
.[]? # optional iterate
.foo.bar # chaining
.foo | length # pipes
# Literals
42, 3.14 # numbers
"hello" # strings
true, false # booleans
null # null
# Comparisons
.x == 5 # equal
.x != "foo" # not equal
.x < 10 # less than
.x <= 10 # less or equal
.x > 0 # greater than
.x >= 0 # greater or equal
# Boolean operators
.a and .b # logical and
.a or .b # logical or
.x > 0 and .x < 10 # compound conditions
# Functions
map(.foo) # apply to each element
select(.x > 5) # filter by condition
# Construction
[.a, .b] # array
{name: .foo} # object
{(.key): .val} # dynamic key
Builtins
length, keys, values, type, first, last, reverse, sort, min, max, unique, flatten, add, empty, not
Functions
map(f)- Apply filterfto each element of an arrayselect(f)- Output the input iffis truthy (notfalseornull)
Building
License
MIT