jc: JSON Convert CLI Tool and Python Library

1.25.6 · active · verified Wed Apr 15

jc is a CLI tool and Python library that converts the output of popular command-line tools and file-types to JSON, YAML, or Python dictionaries. This allows for easier parsing in scripts and seamless integration with tools like `jq`. The library is actively maintained with frequent releases, typically on a monthly or bi-monthly cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `jc` to parse the output of a command-line tool. It captures command output using `subprocess.check_output` and then uses `jc.parse()` with the appropriate parser name ('dig', 'df') to convert it into a Python dictionary or list of dictionaries.

import subprocess
import jc

# Example: Parse 'dig example.com' output
cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
data = jc.parse('dig', cmd_output)

# The result is a Python list of dictionaries
print(data[0]['answer'])

# Example: Parse 'df' output
df_output = subprocess.check_output(['df', '-h'], text=True)
df_data = jc.parse('df', df_output)
print(df_data[0]['filesystem'])

view raw JSON →