Get started with jdig
jdig is JSON Digger’s viewer for the terminal. It opens JSON and NDJSON files of any size; compressed files must be decompressed first. Use it over SSH, in scripts, or whenever you are already in a terminal.
In this tutorial you open a small file, find a value, and quit. It takes about five minutes.
Before you start
Section titled “Before you start”- Download
jdigfor your system from the JSON Digger download page and put it in a folder on yourPATH. - Open a terminal that shows 24-bit color, such as Windows Terminal, iTerm2, or most Linux terminals.
- Save the
orders.jsonsample from Explore your first file in the current folder.
Open a file
Section titled “Open a file”Run:
jdig orders.jsonThe screen has three parts:
- Tree: on the left, with the root
$selected and already expanded. Objects show{N keys}and arrays[N items]. - Details: on the right, the selected node’s type, path, value, and depth, and the number of children of an object or array.
- Status bar: at the bottom, with the file name, its format and size, and the selected row, such as
Row 1 of 3.
Move through the tree
Section titled “Move through the tree”- Press j twice to move down to
"orders", then l to expand it. The cursor moves to its first element,[0]. - Press l again.
[0]expands, and the cursor moves to its first member,"id". - Press h to go back up to
[0], and h again to collapse it.
The arrow keys work too: Down and Up move, Right expands, Left collapses. If your terminal allows it, you can also click a row.
Search
Section titled “Search”- Press /. A
/prompt appears at the bottom. - Type
pendingand press Enter.
The tree expands to the match and moves the cursor to it, "status": "pending", and the details show its path, $.orders[1].status. Press n for the next match; there is only one here.
Press q. Press ? at any time to see a summary of the keys.
Next steps
Section titled “Next steps”- Navigate and search in jdig: expanding, regex search, jq and JSONPath queries, and copying.
- jdig command line: reading from a pipe and running queries in scripts.
- Configure jdig: colors, the panel width, and the mouse.