I’m excited to announce the release of jc
version 1.20.0 available on github and pypi. jc
now supports over 100 standard and streaming parsers. Thank you to the Open Source community for making this possible!
jc
can be installed via pip
or through several official OS package repositories, including Debian, Ubuntu, Fedora, openSUSE, Arch Linux, NixOS Linux, Guix System Linux, FreeBSD, and macOS. For more information on how to get jc
, see the project README.
To upgrade with pip
:
$ pip3 install --upgrade jc
What’s New
- Add YAML output option with the
-y
option - Add
top -b
standard and streaming parsers tested on linux - Add
plugin_parser_count
,standard_parser_count
, andstreaming_parser_count
keys tojc -a
output - Add
is_compatible
function to theutils
module - Fix
pip-show
parser for packages with a multi-line license field - Fix ASCII Table parser for cases where centered headers cause mis-aligned fields
New Parsers
top -b
command parser
Support for the top -b
command. (Documentation)
$ top -b -n 3 | jc --top -p [ { "time": "11:20:43", "uptime": 118, "users": 2, "load_1m": 0.0, "load_5m": 0.01, "load_15m": 0.05, "tasks_total": 108, "tasks_running": 2, "tasks_sleeping": 106, "tasks_stopped": 0, "tasks_zombie": 0, "cpu_user": 5.6, "cpu_sys": 11.1, "cpu_nice": 0.0, "cpu_idle": 83.3, "cpu_wait": 0.0, "cpu_hardware": 0.0, "cpu_software": 0.0, "cpu_steal": 0.0, "mem_total": 3.7, "mem_free": 3.3, "mem_used": 0.2, "mem_buff_cache": 0.2, "swap_total": 2.0, "swap_free": 2.0, "swap_used": 0.0, "mem_available": 3.3, "processes": [ { "pid": 2225, "user": "kbrazil", "priority": 20, "nice": 0, "virtual_mem": 158.1, "resident_mem": 2.2, "shared_mem": 1.6, "status": "running", "percent_cpu": 12.5, "percent_mem": 0.1, "time_hundredths": "0:00.02", "command": "top", "parent_pid": 1884, "uid": 1000, "real_uid": 1000, "real_user": "kbrazil", "saved_uid": 1000, "saved_user": "kbrazil", "gid": 1000, "group": "kbrazil", "pgrp": 2225, "tty": "pts/0", "tty_process_gid": 2225, "session_id": 1884, "thread_count": 1, "last_used_processor": 0, "time": "0:00", "swap": 0.0, "code": 0.1, "data": 1.0, "major_page_fault_count": 0, "minor_page_fault_count": 736, "dirty_pages_count": 0, "sleeping_in_function": null, "flags": "..4.2...", "cgroups": "1:name=systemd:/user.slice/user-1000.+", "supplementary_gids": [ 10, 1000 ], "supplementary_groups": [ "wheel", "kbrazil" ], "thread_gid": 2225, "environment_variables": [ "XDG_SESSION_ID=2", "HOSTNAME=localhost" ], "major_page_fault_count_delta": 0, "minor_page_fault_count_delta": 4, "used": 2.2, "ipc_namespace_inode": 4026531839, "mount_namespace_inode": 4026531840, "net_namespace_inode": 4026531956, "pid_namespace_inode": 4026531836, "user_namespace_inode": 4026531837, "nts_namespace_inode": 4026531838 }, ... ] } ]
top -b
command streaming parser
Support for the top -b
command. This is a streaming parser and it outputs JSON Lines. (Documentation):
$ top -b | jc --top-s {"time":"11:24:50","uptime":2,"users":2,"load_1m":0.23,"load_5m":...} ...
v1.20.1 Updates
- Add
postconf -M
parser tested on linux - Update
asciitable
andasciitable-m
parsers to preserve case in key names when using the-r
orraw=True
options. - Add long options (e.g.
--help
,--about
,--pretty
, etc.) - Add shell completions for Bash and Zsh
- Fix
id
parser for cases where the user or group name is not present
postconf -M
command parser
Linux support for the postconf -m
command. (Documentation):
$ postconf -M | jc --postconf -p # or jc -p postconf -M [ { "service_name": "smtp", "service_type": "inet", "private": false, "unprivileged": null, "chroot": true, "wake_up_time": null, "process_limit": null, "command": "smtpd", "no_wake_up_before_first_use": null }, { "service_name": "pickup", "service_type": "unix", "private": false, "unprivileged": null, "chroot": true, "wake_up_time": 60, "process_limit": 1, "command": "pickup", "no_wake_up_before_first_use": false } ]
Long Options
jc
now supports long CLI options:
Options: -a, --about about jc -C, --force-color force color output even when using pipes (overrides -m) -d, --debug debug (double for verbose debug) -h, --help help (--help --parser_name for parser documentation) -m, --monochrome monochrome output -p, --pretty pretty print output -q, --quiet suppress warnings (double to ignore streaming errors) -r, --raw raw output -u, --unbuffer unbuffer output -v, --version version info -y, --yaml-out YAML output -B, --bash-comp gen Bash completion: jc -B > /etc/bash_completion.d/jc -Z, --zsh-comp gen Zsh completion: jc -Z > "${fpath[1]}/_jc"
Shell Completions
Bash and Zsh completions are now available for jc
! If your system is already set up for completions you can run the following to enable completions:
Bash
Linux
$ jc -B > /etc/bash_completion.d/jc
macOS
$ jc -B > /usr/local/etc/bash_completion.d/jc
Zsh
Linux and macOS
$ jc -Z > "${fpath[1]}/_jc"
Happy parsing!