{"id":6386,"library":"jc","title":"jc: JSON Convert CLI Tool and Python Library","description":"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.","status":"active","version":"1.25.6","language":"en","source_language":"en","source_url":"https://github.com/kellyjonbrazil/jc","tags":["cli-tool","json","parsing","automation","utility","system-tools"],"install":[{"cmd":"pip install jc","lang":"bash","label":"Install jc"}],"dependencies":[{"reason":"Required for parsing XML files. If not installed, parsing XML will raise an ImportError.","package":"xmltodict","optional":true},{"reason":"Required for YAML output functionality.","package":"ruamel.yaml","optional":true}],"imports":[{"note":"Most common and recommended way to access the high-level parsing API.","symbol":"jc","correct":"import jc"},{"note":"For directly importing specific parser modules, bypassing the high-level API.","symbol":"jc.parsers.<parser_name>","correct":"import jc.parsers.dig"}],"quickstart":{"code":"import subprocess\nimport jc\n\n# Example: Parse 'dig example.com' output\ncmd_output = subprocess.check_output(['dig', 'example.com'], text=True)\ndata = jc.parse('dig', cmd_output)\n\n# The result is a Python list of dictionaries\nprint(data[0]['answer'])\n\n# Example: Parse 'df' output\ndf_output = subprocess.check_output(['df', '-h'], text=True)\ndf_data = jc.parse('df', df_output)\nprint(df_data[0]['filesystem'])","lang":"python","description":"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."},"warnings":[{"fix":"Replace `jc.parse('iso-datetime', ...)` with `jc.parse('datetime-iso', ...)`.","message":"The `iso-datetime` parser was removed. Use `datetime-iso` instead.","severity":"breaking","affected_versions":"v1.24.0 and later (deprecated since v1.22.1)"},{"fix":"Update scripts that expect `size` as a string or in specific units to handle the new integer (byte) format. Perform explicit unit conversion if human-readable output is desired.","message":"The `size` fields in `df` and `free` parsers were changed to integers and normalized to bytes, regardless of whether human-readable output (`-h`) was used in the original command. Previously, they might have been strings with units.","severity":"gotcha","affected_versions":"v1.25.2 and later"},{"fix":"Ensure all necessary optional dependencies are installed via `pip install jc[xml]` (if extras are defined) or `pip install <dependency_name>` if you plan to use parsers requiring them. For `xmltodict`, install with `pip install xmltodict`.","message":"Attempting to use parsers that rely on optional third-party libraries (e.g., `xmltodict` for XML parsing) without those libraries installed will result in an `ImportError` or a crash.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Check `jc -hhh` on the command line or refer to the documentation to identify parsers compatible with the `--slurp` option before using it.","message":"The `--slurp` functionality (or `slurp=True` in `jc.parse()`) only works with parsers designed for single-line inputs, not with streaming parsers. Using it with unsupported parsers will not yield the expected results.","severity":"gotcha","affected_versions":"v1.25.0 and later"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}