{"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":"python","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,"search_vec":"'activ':54 'allow':38 'autom':73 'bi':65 'bi-month':64 'cadenc':67 'cli':4,12,69 'cli-tool':68 'command':24 'command-lin':23 'convert':3,18 'dictionari':36 'easier':40 'file':29 'file-typ':28 'frequent':57 'integr':46 'jc':1,9 'jq':50 'json':2,32,71 'librari':8,16,52 'like':49 'line':25 'maintain':55 'month':62,66 'output':20 'pars':41,72 'popular':22 'python':7,15,35 'releas':58 'script':43 'seamless':45 'system':76 'system-tool':75 'tool':5,13,26,48,70,77 'type':30 'typic':59 'util':74 'yaml':33","created_at":"2026-04-15T05:35:02.929775+00:00","updated_at":"2026-04-16T15:51:32.582273+00:00","problems":[{"fix":"Ensure `jc` is installed (`pip install jc`) and that your shell's PATH includes the directory where pip installs executables (e.g., `~/.local/bin` on Linux/macOS or `Scripts` folder in Python installation on Windows). You might need to restart your terminal or source your shell's configuration file (e.g., `source ~/.bashrc` or `source ~/.zshrc`).","cause":"The `jc` command-line tool is not found in your system's PATH. This usually happens if `jc` was installed via `pip` but the Python scripts directory is not included in your shell's PATH environment variable, or if installation was incomplete.","error":"jc: command not found"},{"fix":"Install the `jc` library using pip: `pip install jc`. If you are using virtual environments, ensure your environment is activated before installation. If already installed, verify you are running your script with the correct Python interpreter where `jc` is installed.","cause":"The Python interpreter cannot find the `jc` library. This means the library is either not installed in the currently active Python environment, or there's a problem with the Python path.","error":"ModuleNotFoundError: No module named 'jc'"},{"fix":"When using the `jc` CLI, specify the parser using the `--parser_name` option (e.g., `ls -l | jc --ls`). When using the Python library, ensure you pass the correct parser name as the first argument to `jc.parse()` (e.g., `jc.parse('ls', cmd_output)`).","cause":"When using `jc` in certain contexts (like a SaltStack outputter, as seen in search results) or when calling `jc.parse()` without a parser, the library requires explicit specification of which parser to use for the input data.","error":"You must specify a parser for the jc outputter by exporting the JC_PARSER env variable."},{"fix":"Upgrade `jc` to a version that handles BOMs in CSV files (version 1.22.2 or newer is recommended). `pip install --upgrade jc`. Alternatively, ensure your CSV files do not contain a BOM.","cause":"This specific error often occurs when `jc --csv` is used on a CSV file that contains a Byte Order Mark (BOM) at the beginning. The BOM can cause the first column header to be parsed with extraneous hidden characters, leading `jq` to fail when trying to access the column by its expected name.","error":"jq: error (at <stdin>:1): Cannot index array with string \"Date\""}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.25.6","cli_name":"jc","cli_version":"jc version:  1.25.6","type":"library","homepage":null,"github":"https://github.com/kellyjonbrazil/jc","docs":null,"changelog":null,"pypi":"https://pypi.org/project/jc/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}