jc.json
Parse and format JSON input
TLDR
Convert command output to JSON via pipe
Convert command output to JSON via magic syntax
Output pretty JSON via pipe
Output pretty JSON via magic syntax
SYNOPSIS
jc [OPTIONS] [COMMAND]
PARAMETERS
-a, --about
Show jc information (version, author, etc.)
-c, --clear-cache
Clear the jc parser cache
-d, --debug
Show debug messages
-h, --help
Show help message and exit
-n, --pretty
Pretty print JSON output
-p PARSER, --parser=PARSER
Specify a parser to use (e.g., `df`, `ls`)
-q, --quiet
Suppress warning messages
-r, --raw
Output raw JSON data (no pretty printing)
-t, --tee
Also print the raw command output to STDOUT
-v, --version
Show version number and exit
-w, --wide
Force wide output (useful for long lines)
-y, --yaml
Output YAML instead of JSON
-u, --unbuffer
Do not buffer output (useful for piping to other commands)
DESCRIPTION
jc is a command-line tool that parses the output of various Linux commands and converts it into structured JSON format. This allows for easier manipulation and integration of command output into scripts and other applications. Instead of relying on complex regular expressions or text parsing, jc provides pre-built parsers for common commands like `df`, `ls`, `netstat`, `ps`, and many more.
jc aims to streamline automation tasks by providing a consistent and predictable JSON output, regardless of the specific Linux distribution or command version. It simplifies the process of extracting relevant information from command-line tools, making it more efficient to build scripts, analyze system data, and perform other administrative tasks. The tool can be installed using pip `pip install jc` or using your distributions package manager.
jc is extremely useful for integrating linux output into other tools such as Ansible.
CAVEATS
Not all Linux commands are supported by jc. The accuracy of the parsed JSON depends on the specific command and its output format. It's always recommended to verify the parsed output before relying on it in critical applications.
USING JC IN PIPELINES
jc can be used in pipelines to process the output of multiple commands. For example, `ls -l | jc | jq '.[] | {name: .filename, size: .size}'` would list files, parse them with jc, and format the output using `jq` to display only the filename and size.
HISTORY
jc was developed to simplify the process of parsing Linux command output into structured data. It has gained popularity among system administrators and developers who need to automate tasks and integrate command-line tools with other applications. The tool is actively maintained and new parsers are added regularly to support a wider range of commands.
SEE ALSO
jq(1)