Skip to content

ynqa/jnv

Repository files navigation

Text describing the image

ci

jnv is designed for navigating JSON, offering an interactive JSON viewer and jq filter editor.

jnv.gif

Inspired by jid and jiq.

Features

  • Interactive JSON viewer and jq filter editor
    • Syntax highlighting for JSON
    • Use jaq to apply jq filter
      • This eliminates the need for users to prepare jq on their own.

Important

Starting from v0.3.0, the transition from libjq Rust binding j9 to jq clone jaq was made.

This change eliminated the need to manage C-related dependencies that include external tools like autoconf, thus simplifying the build process. However, please note that some filters are not yet supported by jaq. For more details, refer to GitHub issue #24.

Please continue to provide feedback regarding this transition.

Installation

Homebrew

See here for more info.

brew install jnv

Or install via Homebrew Tap:

brew install ynqa/tap/jnv

MacPorts

See here for more info.

sudo port install jnv

Nix / NixOS

See package entry on search.nixos.org for more info.

nix-shell -p jnv

conda-forge

See here for more info.

pixi global install jnv
# or
cat data.json | pixi exec jnv
# or
conda install jnv

Docker

Build (In the near future, the image will be available on something of registries)

docker build -t jnv .

And Run (The following commad is just an example. Please modify the path to the file you want to mount)

docker run -it --rm -v $(pwd)/debug.json:/jnv/debug.json jnv /jnv/debug.json

Cargo

cargo install jnv

Examples

cat data.json | jnv
# or
jnv data.json

Keymap

Key Action
Ctrl + C Exit
Ctrl + Q Copy jq filter to clipboard
Ctrl + O Copy JSON to clipboard
Shift + ↑, Shift + ↓ Switch to another mode

Editor mode (default)

Key Action
Tab Enter suggestion
Move cursor left
Move cursor right
Ctrl + A Move cursor to line start
Ctrl + E Move cursor to line end
Backspace Delete character before cursor
Ctrl + U Clear entire line
Alt + B Move the cursor to the previous nearest character within set(.,|,(,),[,])
Alt + F Move the cursor to the next nearest character within set(.,|,(,),[,])
Ctrl + W Erase to the previous nearest character within set(.,|,(,),[,])
Alt + D Erase to the next nearest character within set(.,|,(,),[,])

Suggestion in Editor (after Tab)

Key Action
Tab, Select next suggestion
Select previous suggestion
Others Return to editor

JSON viewer mode

Key Action
, Ctrl + K Move up
, Ctrl + J Move down
Ctrl + H Move to last entry
Ctrl + L Move to first entry
Enter Toggle fold
Ctrl + P Expand all
Ctrl + N Collapse all

Usage

SON navigator and interactive filter leveraging jq

Usage: jnv [OPTIONS] [INPUT]

Examples:
- Read from a file:
        jnv data.json

- Read from standard input:
        cat data.json | jnv

Arguments:
  [INPUT]  Optional path to a JSON file. If not provided or if "-" is specified, reads from standard input

Options:
  -e, --edit-mode <EDIT_MODE>      Edit mode for the interface ('insert' or 'overwrite'). [default: insert]
  -i, --indent <INDENT>            Number of spaces used for indentation in the visualized data. [default: 2]
  -n, --no-hint                    Disables the display of hints.
      --max-streams <MAX_STREAMS>  Maximum number of JSON streams to display
      --suggestions <SUGGESTIONS>  Number of autocomplete suggestions to show [default: 3]
  -h, --help                       Print help (see more with '--help')
  -V, --version                    Print version

Stargazers over time

Stargazers over time