HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/json.cpython-310.pyc
o

�N�g��@spdZddlZddlZddlZddlZe�e�Zej	Z	dd�Z
dd�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�ZdS)z
Functions to work with JSON
�NcCs|��S)z�
    Performs a splitlines on the string. This function exists to make mocking
    possible in unit tests, since the member functions of the str/unicode
    builtins cannot be mocked.
    )�
splitlines)�raw�r�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/json.py�__splitsrcCs�i}t|�}ttt|��}g}g}t|�D].\}}|��}|r#|dn|}|dks-|dkr4|�||f�|dks<|dkrC|�||f�qg}|D]1\}	}
t|�D](\}}||	krx|
dkr`|dksh|
dkrx|dkrx|�|	|t||	|d��f�qPqH|j	dd�d	d
�|D]+\}	}}
||��d}d�
||	|��|}z
t�|�}|WSt
y�Yq�wt|�D]>\}}
zd�
||d��}Wnty�d�
tjj�||d���}Ynwzt�|�}Wn	t
y�Yq�w|r�|Sq�|s�t
�dS)
z�
    Pass in a raw string and load the json when it starts. This allows for a
    string to start or end with garbage but the JSON be cleanly loaded
    r�{�[�}�]�cSs|d|d|d|dfS)N�rrr)�xrrr�<lambda>;szfind_json.<locals>.<lambda>T)�key�reverse�
N)r�list�map�len�	enumerate�lstrip�append�reversed�sum�sort�join�json�loads�
ValueError�UnicodeDecodeError�salt�utils�data�decode)r�ret�linesZlengthsZstartsZendsZind�lineZstarts_ends�startZ
start_char�endZend_br�_Zend_strZworkingrrr�	find_jsonsb� ��

� ����r*c	Cs>dD]}zt|�}t�d|�|WStyYqwdS)zU
    Import a json module, starting with the quick ones and going down the list)
    )ZujsonZyajlrzloaded %s json libN)�
__import__�logZtrace�ImportError)Z	fast_json�modrrr�import_jsonYs
��r/cKs|�dt�j|fi|��S)z�
    .. versionadded:: 2018.3.0

    Wraps json.load

    You can pass an alternate json module (loaded via import_json() above)
    using the _json_module argument)
    �_json_module)�popr�load)�fp�kwargsrrrr2fs	r2c
Ksn|�dt�}z
|j|fi|��WSty6}zt|t�r1|jtjj�	|�fi|��WYd}~S�d}~ww)a)
    .. versionadded:: 2018.3.0

    Wraps json.loads and prevents a traceback in the event that a bytestring is
    passed to the function. (Python < 3.6 cannot load bytestrings)

    You can pass an alternate json module (loaded via import_json() above)
    using the _json_module argument)
    r0N)
r1rr�	TypeError�
isinstance�bytesr r!ZstringutilsZ
to_unicode)�sr4�json_module�excrrrrrs

(��rcKs0|�dt�}d|vrd|d<|j||fi|��S)a

    .. versionadded:: 2018.3.0

    Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly
    passed as True) for unicode compatibility. Note that setting it to True
    will mess up any unicode characters, as they will be dumped as the string
    literal version of the unicode code point.

    On Python 2, encodes the result to a str since json.dump does not want
    unicode types.

    You can pass an alternate json module (loaded via import_json() above)
    using the _json_module argument)
    r0�ensure_asciiF)r1r�dump)�objr3r4r9rrrr<�sr<cKs.|�dt�}d|vrd|d<|j|fi|��S)a
    .. versionadded:: 2018.3.0

    Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly
    passed as True) for unicode compatibility. Note that setting it to True
    will mess up any unicode characters, as they will be dumped as the string
    literal version of the unicode code point.

    On Python 2, encodes the result to a str since json.dumps does not want
    unicode types.

    You can pass an alternate json module (loaded via import_json() above)
    using the _json_module argument)
    r0r;F)r1r�dumps)r=r4r9rrrr>�sr>)�__doc__r�loggingZsalt.utils.datar Zsalt.utils.stringutils�	getLogger�__name__r,�JSONEncoderrr*r/r2rr<r>rrrr�<module>s
	>