π

JSON to a table with jtbl

Show Sidebar

jtbl is a Python programm to convert JSON from STDIN to table. It could be installed via GNU Guix package manager from ace3e549 commit.

The following example demonstrates ifconfig command output converted to JSON with jc utility, piped to jq to filter, and to jtbl generate a table:

  ifconfig \
   | jc --ifconfig \
   | jq --raw-output "[.[] | {\"interface\": .name, \"ipv4_addr\": .ipv4_addr}]" \
   | jtbl	  

#+RESULTS:

interface ipv4addr
————— —————
br-92487ea26a13 172.20.0.1
br-9a47a96d15a3 172.19.0.1
br-cf57cf7f08d8 172.18.0.1
br-fc2bf1eb0e5a 10.10.100.1
docker0 172.17.0.1
enp6s0 192.168.100.120
lo 127.0.0.1
tapvpn 172.16.103.177

Comment via email or via Disqus comments below: