community / community.general / 6.6.8 / filter / jc Convert output of many shell commands and file-types to JSON | "added in version" 1.1.0 of community.general" Authors: Kelly Brazil (@kellyjonbrazil)community.general.jc (6.6.8) — filter
Install with ansible-galaxy collection install community.general:==6.6.8
collections: - name: community.general version: 6.6.8
Convert output of many shell commands and file-types to JSON.
Uses the L(jc library,https://github.com/kellyjonbrazil/jc).
- name: Install the prereqs of the jc filter (jc Python package) on the Ansible controller delegate_to: localhost ansible.builtin.pip: name: jc state: present
- name: Run command ansible.builtin.command: uname -a register: result
- name: Convert command's result to JSON ansible.builtin.debug: msg: "{{ result.stdout | community.general.jc('uname') }}"
raw: default: false description: Set to C(true) to return pre-processed JSON. type: boolean quiet: default: true description: Set to C(false) to not suppress warnings. type: boolean _input: description: The data to convert. required: true type: string parser: description: - The correct parser for the input data. - For example C(ifconfig). - 'Note: use underscores instead of dashes (if any) in the parser module name.' - See U(https://github.com/kellyjonbrazil/jc#parsers) for the latest list of parsers. required: true type: string
_value: description: The processed output. type: any