jtbl


Namejtbl JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/kellyjonbrazil/jtbl
SummaryA simple cli tool to print JSON and JSON Lines data as a table in the terminal.
upload_time2023-12-12 00:48:21
maintainer
docs_urlNone
authorKelly Brazil
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements tabulate
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Tests](https://github.com/kellyjonbrazil/jtbl/workflows/Tests/badge.svg?branch=master)](https://github.com/kellyjonbrazil/jtbl/actions)
[![Pypi](https://img.shields.io/pypi/v/jtbl.svg)](https://pypi.org/project/jtbl/)

# jtbl
A simple cli tool to print JSON data as a table in the terminal.

`jtbl` accepts piped JSON data from `stdin` and outputs a text table representation to `stdout`. e.g:
```
$ cat cities.json | jtbl
  LatD    LatM    LatS  NS      LonD    LonM    LonS  EW    City               State
------  ------  ------  ----  ------  ------  ------  ----  -----------------  -------
    41       5      59  N         80      39       0  W     Youngstown         OH
    42      52      48  N         97      23      23  W     Yankton            SD
    46      35      59  N        120      30      36  W     Yakima             WA
    42      16      12  N         71      48       0  W     Worcester          MA
    43      37      48  N         89      46      11  W     Wisconsin Dells    WI
    36       5      59  N         80      15       0  W     Winston-Salem      NC
    49      52      48  N         97       9       0  W     Winnipeg           MB
```

`jtbl` expects a JSON array of JSON objects or [JSON Lines](http://jsonlines.org/).

It can be useful to JSONify command line output with `jc`, filter through a tool like `jq`, and present in `jtbl`:
```
$ jc ifconfig | jq -c '.[] | {name, type, ipv4_addr, ipv4_mask}'| jtbl
name     type            ipv4_addr       ipv4_mask
-------  --------------  --------------  -------------
docker0  Ethernet        172.17.0.1      255.255.0.0
ens33    Ethernet        192.168.71.146  255.255.255.0
lo       Local Loopback  127.0.0.1       255.0.0.0
```

## Installation
You can install `jtbl` via `pip`, via OS Package Repositories, MSI installer for Windows, or by downloading the correct binary for your architecture and running it anywhere on your filesystem.

### Pip (macOS, linux, unix, Windows)
For the most up-to-date version and the most cross-platform option, use `pip` or `pip3` to download and install `jtbl` directly from [PyPi](https://pypi.org/project/jtbl/):

[![Pypi](https://img.shields.io/pypi/v/jtbl.svg)](https://pypi.org/project/jtbl/)
```bash
pip3 install jtbl
```

### OS Packages

[![Packaging status](https://repology.org/badge/vertical-allrepos/jtbl.svg)](https://repology.org/project/jtbl/versions)

See [Releases](https://github.com/kellyjonbrazil/jtbl/releases) on Github for MSI packages and binaries.

## Usage
Just pipe JSON data to `jtbl`. (e.g. `cat` a JSON file, `jc`, `jq`, `aws` cli, `kubectl`, etc.)
```
$ <JSON Data> | jtbl [OPTIONS]
```
### Options
- `--cols=n` manually configure the terminal width
- `-c` CSV table output
- `-f` fancy table output
- `-h` help - prints help information
- `-H` HTML table output
- `-m` markdown table output
- `-n` no-wrap - no data wrapping if too long for the terminal width (overrides `--cols` and `-t`)
- `-q` quiet - don't print error messages to STDERR
- `-r` rotate the data (each row turns into a table of key/value pairs)
- `-t` truncate data instead of wrapping if too long for the terminal width
- `-v` prints version information

## Compatible JSON Formats
`jtbl` works best with a shallow array of JSON objects. Each object should have a few elements that will be turned into table columns. Fortunately, this is how many APIs present their data.

**JSON Array Example**
```
[
  {
    "unit": "proc-sys-fs-binfmt_misc.automount",
    "load": "loaded",
    "active": "active",
    "sub": "waiting",
    "description": "Arbitrary Executable File Formats File System Automount Point"
  },
  {
    "unit": "sys-devices-pci0000:00-0000:00:07.1-ata2-host2-target2:0:0-2:0:0:0-block-sr0.device",
    "load": "loaded",
    "active": "active",
    "sub": "plugged",
    "description": "VMware_Virtual_IDE_CDROM_Drive"
  },
  ...
]
```

`jtbl` can also work with [JSON Lines](http://jsonlines.org/) format with similar features.

**JSON Lines Example**
```
{"name": "docker0", type": "Ethernet", "ipv4_addr": "172.17.0.1", "ipv4_mask": "255.255.0.0"}
{"name": "ens33", "type": "Ethernet", "ipv4_addr": "192.168.71.146", "ipv4_mask": "255.255.255.0"}
{"name": "lo", "type": "Local Loopback", "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0"}
...
```

## Filtering the JSON Input
If there are too many elements, or the data in the elements are too large, the table may not fit in the terminal screen. In this case you can use a JSON filter like `jq` or `jello` to send `jtbl` only the elements you are interested in:

### `jq` Array Method
The following example uses `jq` to filter and format the filtered elements into a proper JSON array.
```
$ cat /etc/passwd | jc --passwd | jq '[.[] | {username, shell}]'
[
  {
    "username": "root",
    "shell": "/bin/bash"
  },
  {
    "username": "bin",
    "shell": "/sbin/nologin"
  },
  {
    "username": "daemon",
    "shell": "/sbin/nologin"
  },
  ...
]
```
*(Notice the square brackets around the filter)*

### `jq` Slurp Method
The following example uses `jq` to filter and 'slurp' the filtered elements into a proper JSON array.
```
$ cat /etc/passwd | jc --passwd | jq '.[] | {username, shell}' | jq -s
[
  {
    "username": "root",
    "shell": "/bin/bash"
  },
  {
    "username": "bin",
    "shell": "/sbin/nologin"
  },
  {
    "username": "daemon",
    "shell": "/sbin/nologin"
  },
  ...
]
```
*(Notice the `jq -s` at the end)*

### `jq` JSON Lines Method
The following example will send the data in JSON Lines format, which `jtbl` can understand:
```
$ cat /etc/passwd | jc --passwd | jq -c '.[] | {username, shell}'
{"username":"root","shell":"/bin/bash"}
{"username":"bin","shell":"/sbin/nologin"}
{"username":"daemon","shell":"/sbin/nologin"}
...
```
*(Notice the `-c` option being used)*

### `jello` List Comprehension Method
If you prefer python list and dictionary syntax to filter JSON data, you can use `jello`:
```
$ cat /etc/passwd | jc --passwd | jello '[{"username": x.username, "shell": x.shell} for x in _]'
[
  {
    "username": "root",
    "shell": "/bin/bash"
  },
  {
    "username": "bin",
    "shell": "/sbin/nologin"
  },
  {
    "username": "daemon",
    "shell": "/sbin/nologin"
  },
  ...
]
```

When piping any of these to `jtbl` you get the following result:
```
$ cat /etc/passwd | jc --passwd | jello '[{"username": x.username, "shell": x.shell} for x in _]' | jtbl
username         shell
---------------  --------------
root             /bin/bash
bin              /sbin/nologin
daemon           /sbin/nologin
...
```

## Working with Deeper JSON Structures
`jtbl` will happily dump deeply nested JSON structures into a table, but usually this is not what you are looking for.
```
$ jc dig www.cnn.com | jtbl
╒══════════╤══════════╤═══════╤════════════╤═════════════╤══════════════╤══════════════╤══════════════╤══════════════╤════════════╤════════════╤══════════════╤════════════╤════════════╤════════╤══════════════╤══════════════╕
│ opcode   │ status   │    id │ flags      │   query_num │   answer_num │   authority_ │   additional │ opt_pseudo   │ question   │ answer     │   query_time │ server     │ when       │   rcvd │   when_epoch │ when_epoch   │
│          │          │       │            │             │              │          num │         _num │ section      │            │            │              │            │            │        │              │ _utc         │
╞══════════╪══════════╪═══════╪════════════╪═════════════╪══════════════╪══════════════╪══════════════╪══════════════╪════════════╪════════════╪══════════════╪════════════╪════════════╪════════╪══════════════╪══════════════╡
│ QUERY    │ NOERROR  │ 36494 │ ['qr', 'rd │           1 │            4 │            0 │            1 │ {'edns': {   │ {'name': ' │ [{'name':  │           47 │ 2600:1700: │ Wed Dec 22 │    100 │   1640200072 │              │
│          │          │       │ ', 'ra']   │             │              │              │              │ 'version':   │ cnn.com.', │ 'cnn.com.' │              │ bab0:d40:: │  11:07:52  │        │              │              │
│          │          │       │            │             │              │              │              │  0, 'flags   │  'class':  │ , 'class': │              │ 1#53(2600: │ PST 2021   │        │              │              │
│          │          │       │            │             │              │              │              │ ': [], 'ud   │ 'IN', 'typ │  'IN', 'ty │              │ 1700:bab0: │            │        │              │              │
│          │          │       │            │             │              │              │              │ p': 4096}}   │ e': 'A'}   │ pe': 'A',  │              │ d40::1)    │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │ 'ttl': 60, │              │            │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │  'data': ' │              │            │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │ 151.101.12 │              │            │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │ 9.67'}, {' │              │            │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │ name': 'cn │              │            │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │ n.com.', ' │              │            │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │ class': 'I │              │            │            │        │              │              │
│          │          │       │            │             │              │              │              │              │            │ ...        │              │            │            │        │              │              │
╘══════════╧══════════╧═══════╧════════════╧═════════════╧══════════════╧══════════════╧══════════════╧══════════════╧════════════╧════════════╧══════════════╧════════════╧════════════╧════════╧══════════════╧══════════════╛
```

## Diving Deeper into the JSON with `jq` or `jello`:
To get to the data you are interested in you can use a JSON filter like `jq` or `jello` to dive deeper.

Using `jq`:
```
$ jc dig www.cnn.com | jq '.[0].answer'
```
or with `jello`:
```
$ jc dig www.cnn.com | jello '_[0].answer'
```
Both will produce the following output:
```
[
  {
    "name": "www.cnn.com.",
    "class": "IN",
    "type": "CNAME",
    "ttl": 90,
    "data": "turner-tls.map.fastly.net."
  },
  {
    "name": "turner-tls.map.fastly.net.",
    "class": "IN",
    "type": "A",
    "ttl": 20,
    "data": "151.101.1.67"
  }
  ...
]
```

This will produce the following table in `jtbl`
```
$ jc dig www.cnn.com | jello '_[0].answer' | jtbl
name                        class    type      ttl  data
--------------------------  -------  ------  -----  --------------------------
www.cnn.com.                IN       CNAME      11  turner-tls.map.fastly.net.
turner-tls.map.fastly.net.  IN       A          23  151.101.129.67
turner-tls.map.fastly.net.  IN       A          23  151.101.1.67
turner-tls.map.fastly.net.  IN       A          23  151.101.65.67
turner-tls.map.fastly.net.  IN       A          23  151.101.193.67

```

## Column Width
`jtbl` will attempt to shrink columns to a sane size if it detects the output is wider than the terminal width. The `--cols` option will override the automatic terminal width detection.

You can use the `-t` option to truncate the rows instead of wrapping when the terminal width is too small for all of the data.

The `-n` option disables wrapping and overrides the `--cols` and `-t` options.

This can be useful to present a nicely non-wrapped table of infinite width in combination with `less -S`:
```
$ jc ps aux | jtbl -n | less -S
user                  pid        vsz     rss  tt    stat    started    time       command
------------------  -----  ---------  ------  ----  ------  ---------  ---------  ---------------------------------------------------
joeuser             34029    4277364   24800  s000  S+      9:28AM     0:00.27    /usr/local/Cellar/python/3.7.6_1/Frameworks/Python....
joeuser             34030    4283136   17104  s000  S+      9:28AM     0:00.20    /usr/local/Cellar/python/3.7.6_1/Frameworks/Python....
joeuser               481    5728568  189328        S       17Apr20    21:46.52   /Applications/Utilities/Terminal.app/Contents/MacOS...
joeuser             45827    6089084  693768        S       Wed01PM    84:54.87   /Applications/Microsoft Teams.app/Contents/Framewor...
joeuser              1493    9338824  911600        S       17Apr20    143:27.08  /Applications/Microsoft Outlook.app/Contents/MacOS/...
joeuser             45822    5851524  163840        S       Wed01PM    38:48.83   /Applications/Microsoft Teams.app/Contents/MacOS/Te...
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kellyjonbrazil/jtbl",
    "name": "jtbl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Kelly Brazil",
    "author_email": "kellyjonbrazil@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9e/7c/b21f3383ca611b56dbc281081cca73a24274c3f39654e7fe196d73a67af6/jtbl-1.6.0.tar.gz",
    "platform": null,
    "description": "[![Tests](https://github.com/kellyjonbrazil/jtbl/workflows/Tests/badge.svg?branch=master)](https://github.com/kellyjonbrazil/jtbl/actions)\n[![Pypi](https://img.shields.io/pypi/v/jtbl.svg)](https://pypi.org/project/jtbl/)\n\n# jtbl\nA simple cli tool to print JSON data as a table in the terminal.\n\n`jtbl` accepts piped JSON data from `stdin` and outputs a text table representation to `stdout`. e.g:\n```\n$ cat cities.json | jtbl\n  LatD    LatM    LatS  NS      LonD    LonM    LonS  EW    City               State\n------  ------  ------  ----  ------  ------  ------  ----  -----------------  -------\n    41       5      59  N         80      39       0  W     Youngstown         OH\n    42      52      48  N         97      23      23  W     Yankton            SD\n    46      35      59  N        120      30      36  W     Yakima             WA\n    42      16      12  N         71      48       0  W     Worcester          MA\n    43      37      48  N         89      46      11  W     Wisconsin Dells    WI\n    36       5      59  N         80      15       0  W     Winston-Salem      NC\n    49      52      48  N         97       9       0  W     Winnipeg           MB\n```\n\n`jtbl` expects a JSON array of JSON objects or [JSON Lines](http://jsonlines.org/).\n\nIt can be useful to JSONify command line output with `jc`, filter through a tool like `jq`, and present in `jtbl`:\n```\n$ jc ifconfig | jq -c '.[] | {name, type, ipv4_addr, ipv4_mask}'| jtbl\nname     type            ipv4_addr       ipv4_mask\n-------  --------------  --------------  -------------\ndocker0  Ethernet        172.17.0.1      255.255.0.0\nens33    Ethernet        192.168.71.146  255.255.255.0\nlo       Local Loopback  127.0.0.1       255.0.0.0\n```\n\n## Installation\nYou can install `jtbl` via `pip`, via OS Package Repositories, MSI installer for Windows, or by downloading the correct binary for your architecture and running it anywhere on your filesystem.\n\n### Pip (macOS, linux, unix, Windows)\nFor the most up-to-date version and the most cross-platform option, use `pip` or `pip3` to download and install `jtbl` directly from [PyPi](https://pypi.org/project/jtbl/):\n\n[![Pypi](https://img.shields.io/pypi/v/jtbl.svg)](https://pypi.org/project/jtbl/)\n```bash\npip3 install jtbl\n```\n\n### OS Packages\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/jtbl.svg)](https://repology.org/project/jtbl/versions)\n\nSee [Releases](https://github.com/kellyjonbrazil/jtbl/releases) on Github for MSI packages and binaries.\n\n## Usage\nJust pipe JSON data to `jtbl`. (e.g. `cat` a JSON file, `jc`, `jq`, `aws` cli, `kubectl`, etc.)\n```\n$ <JSON Data> | jtbl [OPTIONS]\n```\n### Options\n- `--cols=n` manually configure the terminal width\n- `-c` CSV table output\n- `-f` fancy table output\n- `-h` help - prints help information\n- `-H` HTML table output\n- `-m` markdown table output\n- `-n` no-wrap - no data wrapping if too long for the terminal width (overrides `--cols` and `-t`)\n- `-q` quiet - don't print error messages to STDERR\n- `-r` rotate the data (each row turns into a table of key/value pairs)\n- `-t` truncate data instead of wrapping if too long for the terminal width\n- `-v` prints version information\n\n## Compatible JSON Formats\n`jtbl` works best with a shallow array of JSON objects. Each object should have a few elements that will be turned into table columns. Fortunately, this is how many APIs present their data.\n\n**JSON Array Example**\n```\n[\n  {\n    \"unit\": \"proc-sys-fs-binfmt_misc.automount\",\n    \"load\": \"loaded\",\n    \"active\": \"active\",\n    \"sub\": \"waiting\",\n    \"description\": \"Arbitrary Executable File Formats File System Automount Point\"\n  },\n  {\n    \"unit\": \"sys-devices-pci0000:00-0000:00:07.1-ata2-host2-target2:0:0-2:0:0:0-block-sr0.device\",\n    \"load\": \"loaded\",\n    \"active\": \"active\",\n    \"sub\": \"plugged\",\n    \"description\": \"VMware_Virtual_IDE_CDROM_Drive\"\n  },\n  ...\n]\n```\n\n`jtbl` can also work with [JSON Lines](http://jsonlines.org/) format with similar features.\n\n**JSON Lines Example**\n```\n{\"name\": \"docker0\", type\": \"Ethernet\", \"ipv4_addr\": \"172.17.0.1\", \"ipv4_mask\": \"255.255.0.0\"}\n{\"name\": \"ens33\", \"type\": \"Ethernet\", \"ipv4_addr\": \"192.168.71.146\", \"ipv4_mask\": \"255.255.255.0\"}\n{\"name\": \"lo\", \"type\": \"Local Loopback\", \"ipv4_addr\": \"127.0.0.1\", \"ipv4_mask\": \"255.0.0.0\"}\n...\n```\n\n## Filtering the JSON Input\nIf there are too many elements, or the data in the elements are too large, the table may not fit in the terminal screen. In this case you can use a JSON filter like `jq` or `jello` to send `jtbl` only the elements you are interested in:\n\n### `jq` Array Method\nThe following example uses `jq` to filter and format the filtered elements into a proper JSON array.\n```\n$ cat /etc/passwd | jc --passwd | jq '[.[] | {username, shell}]'\n[\n  {\n    \"username\": \"root\",\n    \"shell\": \"/bin/bash\"\n  },\n  {\n    \"username\": \"bin\",\n    \"shell\": \"/sbin/nologin\"\n  },\n  {\n    \"username\": \"daemon\",\n    \"shell\": \"/sbin/nologin\"\n  },\n  ...\n]\n```\n*(Notice the square brackets around the filter)*\n\n### `jq` Slurp Method\nThe following example uses `jq` to filter and 'slurp' the filtered elements into a proper JSON array.\n```\n$ cat /etc/passwd | jc --passwd | jq '.[] | {username, shell}' | jq -s\n[\n  {\n    \"username\": \"root\",\n    \"shell\": \"/bin/bash\"\n  },\n  {\n    \"username\": \"bin\",\n    \"shell\": \"/sbin/nologin\"\n  },\n  {\n    \"username\": \"daemon\",\n    \"shell\": \"/sbin/nologin\"\n  },\n  ...\n]\n```\n*(Notice the `jq -s` at the end)*\n\n### `jq` JSON Lines Method\nThe following example will send the data in JSON Lines format, which `jtbl` can understand:\n```\n$ cat /etc/passwd | jc --passwd | jq -c '.[] | {username, shell}'\n{\"username\":\"root\",\"shell\":\"/bin/bash\"}\n{\"username\":\"bin\",\"shell\":\"/sbin/nologin\"}\n{\"username\":\"daemon\",\"shell\":\"/sbin/nologin\"}\n...\n```\n*(Notice the `-c` option being used)*\n\n### `jello` List Comprehension Method\nIf you prefer python list and dictionary syntax to filter JSON data, you can use `jello`:\n```\n$ cat /etc/passwd | jc --passwd | jello '[{\"username\": x.username, \"shell\": x.shell} for x in _]'\n[\n  {\n    \"username\": \"root\",\n    \"shell\": \"/bin/bash\"\n  },\n  {\n    \"username\": \"bin\",\n    \"shell\": \"/sbin/nologin\"\n  },\n  {\n    \"username\": \"daemon\",\n    \"shell\": \"/sbin/nologin\"\n  },\n  ...\n]\n```\n\nWhen piping any of these to `jtbl` you get the following result:\n```\n$ cat /etc/passwd | jc --passwd | jello '[{\"username\": x.username, \"shell\": x.shell} for x in _]' | jtbl\nusername         shell\n---------------  --------------\nroot             /bin/bash\nbin              /sbin/nologin\ndaemon           /sbin/nologin\n...\n```\n\n## Working with Deeper JSON Structures\n`jtbl` will happily dump deeply nested JSON structures into a table, but usually this is not what you are looking for.\n```\n$ jc dig www.cnn.com | jtbl\n\u2552\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2555\n\u2502 opcode   \u2502 status   \u2502    id \u2502 flags      \u2502   query_num \u2502   answer_num \u2502   authority_ \u2502   additional \u2502 opt_pseudo   \u2502 question   \u2502 answer     \u2502   query_time \u2502 server     \u2502 when       \u2502   rcvd \u2502   when_epoch \u2502 when_epoch   \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502          num \u2502         _num \u2502 section      \u2502            \u2502            \u2502              \u2502            \u2502            \u2502        \u2502              \u2502 _utc         \u2502\n\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n\u2502 QUERY    \u2502 NOERROR  \u2502 36494 \u2502 ['qr', 'rd \u2502           1 \u2502            4 \u2502            0 \u2502            1 \u2502 {'edns': {   \u2502 {'name': ' \u2502 [{'name':  \u2502           47 \u2502 2600:1700: \u2502 Wed Dec 22 \u2502    100 \u2502   1640200072 \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502 ', 'ra']   \u2502             \u2502              \u2502              \u2502              \u2502 'version':   \u2502 cnn.com.', \u2502 'cnn.com.' \u2502              \u2502 bab0:d40:: \u2502  11:07:52  \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502  0, 'flags   \u2502  'class':  \u2502 , 'class': \u2502              \u2502 1#53(2600: \u2502 PST 2021   \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502 ': [], 'ud   \u2502 'IN', 'typ \u2502  'IN', 'ty \u2502              \u2502 1700:bab0: \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502 p': 4096}}   \u2502 e': 'A'}   \u2502 pe': 'A',  \u2502              \u2502 d40::1)    \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502 'ttl': 60, \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502  'data': ' \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502 151.101.12 \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502 9.67'}, {' \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502 name': 'cn \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502 n.com.', ' \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502 class': 'I \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2502          \u2502          \u2502       \u2502            \u2502             \u2502              \u2502              \u2502              \u2502              \u2502            \u2502 ...        \u2502              \u2502            \u2502            \u2502        \u2502              \u2502              \u2502\n\u2558\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255b\n```\n\n## Diving Deeper into the JSON with `jq` or `jello`:\nTo get to the data you are interested in you can use a JSON filter like `jq` or `jello` to dive deeper.\n\nUsing `jq`:\n```\n$ jc dig www.cnn.com | jq '.[0].answer'\n```\nor with `jello`:\n```\n$ jc dig www.cnn.com | jello '_[0].answer'\n```\nBoth will produce the following output:\n```\n[\n  {\n    \"name\": \"www.cnn.com.\",\n    \"class\": \"IN\",\n    \"type\": \"CNAME\",\n    \"ttl\": 90,\n    \"data\": \"turner-tls.map.fastly.net.\"\n  },\n  {\n    \"name\": \"turner-tls.map.fastly.net.\",\n    \"class\": \"IN\",\n    \"type\": \"A\",\n    \"ttl\": 20,\n    \"data\": \"151.101.1.67\"\n  }\n  ...\n]\n```\n\nThis will produce the following table in `jtbl`\n```\n$ jc dig www.cnn.com | jello '_[0].answer' | jtbl\nname                        class    type      ttl  data\n--------------------------  -------  ------  -----  --------------------------\nwww.cnn.com.                IN       CNAME      11  turner-tls.map.fastly.net.\nturner-tls.map.fastly.net.  IN       A          23  151.101.129.67\nturner-tls.map.fastly.net.  IN       A          23  151.101.1.67\nturner-tls.map.fastly.net.  IN       A          23  151.101.65.67\nturner-tls.map.fastly.net.  IN       A          23  151.101.193.67\n\n```\n\n## Column Width\n`jtbl` will attempt to shrink columns to a sane size if it detects the output is wider than the terminal width. The `--cols` option will override the automatic terminal width detection.\n\nYou can use the `-t` option to truncate the rows instead of wrapping when the terminal width is too small for all of the data.\n\nThe `-n` option disables wrapping and overrides the `--cols` and `-t` options.\n\nThis can be useful to present a nicely non-wrapped table of infinite width in combination with `less -S`:\n```\n$ jc ps aux | jtbl -n | less -S\nuser                  pid        vsz     rss  tt    stat    started    time       command\n------------------  -----  ---------  ------  ----  ------  ---------  ---------  ---------------------------------------------------\njoeuser             34029    4277364   24800  s000  S+      9:28AM     0:00.27    /usr/local/Cellar/python/3.7.6_1/Frameworks/Python....\njoeuser             34030    4283136   17104  s000  S+      9:28AM     0:00.20    /usr/local/Cellar/python/3.7.6_1/Frameworks/Python....\njoeuser               481    5728568  189328        S       17Apr20    21:46.52   /Applications/Utilities/Terminal.app/Contents/MacOS...\njoeuser             45827    6089084  693768        S       Wed01PM    84:54.87   /Applications/Microsoft Teams.app/Contents/Framewor...\njoeuser              1493    9338824  911600        S       17Apr20    143:27.08  /Applications/Microsoft Outlook.app/Contents/MacOS/...\njoeuser             45822    5851524  163840        S       Wed01PM    38:48.83   /Applications/Microsoft Teams.app/Contents/MacOS/Te...\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple cli tool to print JSON and JSON Lines data as a table in the terminal.",
    "version": "1.6.0",
    "project_urls": {
        "Homepage": "https://github.com/kellyjonbrazil/jtbl"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3a06b685e6b1de15159539ac5579a8498521e9ea972e724705ff9d55750a88c",
                "md5": "1ab7527f6108c342587f88e18667f5d5",
                "sha256": "795c0113a60e65c32d25beb7a8aa15565944cc0cadc7232aeef523cd444324ab"
            },
            "downloads": -1,
            "filename": "jtbl-1.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1ab7527f6108c342587f88e18667f5d5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10083,
            "upload_time": "2023-12-12T00:48:19",
            "upload_time_iso_8601": "2023-12-12T00:48:19.988219Z",
            "url": "https://files.pythonhosted.org/packages/f3/a0/6b685e6b1de15159539ac5579a8498521e9ea972e724705ff9d55750a88c/jtbl-1.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e7cb21f3383ca611b56dbc281081cca73a24274c3f39654e7fe196d73a67af6",
                "md5": "232b5163c375c1a54ff70b1ce675d3ba",
                "sha256": "7de0cb08ebb2b3a0658229a8edd4204c6944cbd9e3e04724a9ea235a61c115a5"
            },
            "downloads": -1,
            "filename": "jtbl-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "232b5163c375c1a54ff70b1ce675d3ba",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 15466,
            "upload_time": "2023-12-12T00:48:21",
            "upload_time_iso_8601": "2023-12-12T00:48:21.980587Z",
            "url": "https://files.pythonhosted.org/packages/9e/7c/b21f3383ca611b56dbc281081cca73a24274c3f39654e7fe196d73a67af6/jtbl-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-12 00:48:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kellyjonbrazil",
    "github_project": "jtbl",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "tabulate",
            "specs": [
                [
                    ">=",
                    "0.8.10"
                ]
            ]
        }
    ],
    "lcname": "jtbl"
}
        
Elapsed time: 0.21012s