File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/serializers/__pycache__/json.cpython-310.pyc
o
�N�g� � @ sd d Z ddlZddlmZmZ zddlZW n
ey! ddl ZY nw g d�Z
dZdd� Zdd � Z
dS )
z�
salt.serializers.json
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Implements JSON serializer.
It's just a wrapper around json (or simplejson if available).
� N)�DeserializationError�SerializationError)�deserialize� serialize� availableTc
K st z)t | ttf�stjjj| fdti|��W S t | t�r | �d�} tjjj | td�W S t
y9 } zt|��d}~ww )z�
Deserialize any string or stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower json/simplejson module.
�_json_modulezutf-8)r N)�
isinstance�bytes�str�salt�utils�json�load�_json�decode�loads� Exceptionr )Zstream_or_string�options�error� r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/serializers/json.pyr s
��r c
K sb z d|v rt jjj| fdti|��W S t jjj| fdti|��W S ty0 } zt|��d}~ww )z�
Serialize Python data to JSON.
:param obj: the data structure to serialize
:param options: options given to lower json/simplejson module.
�fpr N)r r r
�dumpr �dumpsr r )�objr r r r r r , s ��r )�__doc__Zsalt.utils.jsonr Zsalt.serializersr r Z
simplejsonr �ImportErrorr
�__all__r r r r r r r �<module> s �