HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/output/__pycache__/json_out.cpython-310.pyc
o

�N�g�
�@s6dZddlZddlZe�e�ZdZdd�Zdd�Z	dS)a}
Display return data in JSON format
==================================

:configuration: The output format can be configured in two ways:
    Using the ``--out-indent`` CLI flag and specifying a positive integer or a
    negative integer to group JSON from each minion to a single line.

    Or setting the ``output_indent`` setting in the Master or Minion
    configuration file with one of the following values:

    * ``Null``: put each minion return on a single line.
    * ``pretty``: use four-space indents and sort the keys.
    * An integer: specify the indentation level.

Salt's outputters operate on a per-minion basis. Each minion return will be
output as a single JSON object once it comes in to the master.

Some JSON parsers can guess when an object ends and a new one begins but many
can not. A good way to differentiate between each minion return is to use the
single-line output format and to parse each line individually. Example output
(truncated)::

    {"dave": {"en0": {"hwaddr": "02:b0:26:32:4c:69", ...}}}
    {"jerry": {"en0": {"hwaddr": "02:26:ab:0d:b9:0d", ...}}}
    {"kevin": {"en0": {"hwaddr": "02:6d:7f:ce:9f:ee", ...}}}
    {"mike": {"en0": {"hwaddr": "02:48:a2:4b:70:a0", ...}}}
    {"phill": {"en0": {"hwaddr": "02:1d:cc:a2:33:55", ...}}}
    {"stuart": {"en0": {"hwaddr": "02:9a:e0:ea:9e:3c", ...}}}


CLI Example:

.. code-block:: bash

    salt '*' foo.bar --out=json
�N�jsoncCstS)z
    Rename to json
    )�__virtualname__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/output/json_out.py�__virtual__1src
Ks�z=dtvrtjjj|tdd�WSt�d�}d}|durd}n|dkr'd}d}nt|t�r2|dkr2d}tjjj|t||d	�WSt	y`}zt
�d
�tjj�d
t|�d��WYd}~Sd}~wt
yot
jddd
�Ynwtjj�i�S)z'
    Print the output data in JSON
    Z
output_indent�)�default�indentFNZprettyTr)rr	�	sort_keysz"Unable to serialize output to json)�error�messagez'An error occurred while outputting JSON)�exc_info)Z__opts__�salt�utilsr�dumps�repr�get�
isinstance�int�UnicodeDecodeError�logr�str�	TypeError�debug)�data�kwargsr	r
�excrrr�output8s4

�
���r)
�__doc__�loggingZsalt.utils.jsonr�	getLogger�__name__rrrrrrrr�<module>s&