o
    ?Zœcá
  ã                   @   sð   d Z ddlZddlZddlZddlZzddlmZ W n e	y*   G dd„ dƒZY nw zddlZi Z
G dd„ deƒZW n e	yS   ddlZddlmZ d	d	d
œZ
Y nw eejƒZdZG dd„ deƒZeZejddfdd„Zejdfdd„ZdS )zJSON Serialization Utilities.é    N)ÚPromisec                   @   s   e Zd ZdZdS )ÚDjangoPromisezDummy object.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úF/var/www/chikooza/env/lib/python3.10/site-packages/kombu/utils/json.pyr      s    r   c                   @   s   e Zd ZdS )Ú_DecodeErrorN)r   r   r   r   r   r   r	   r
      s    r
   )ÚJSONDecodeErrorF)Úuse_decimalÚnamedtuple_as_objectc                       sF   e Zd ZdZejejfejfeje	j
efeejef‡ fdd„	Z‡  ZS )ÚJSONEncoderzKombu custom json encoder.c           
         sž   t |dd ƒ}|d ur|ƒ S |||ƒr7|||ƒs$||j|j|jddddƒ}| ¡ }	|	 d¡r5|	d d… d }	|	S |||ƒr@| ¡ S |||ƒrI||ƒS tƒ  |¡S )NÚ__json__r   z+00:00iúÿÿÿÚZ)ÚgetattrÚyearÚmonthÚdayÚ	isoformatÚendswithÚsuperÚdefault)
ÚselfÚoÚdatesÚtimesÚtextualÚ
isinstanceÚdatetimeÚtext_tÚreducerÚr©Ú	__class__r   r	   r   $   s   




zJSONEncoder.default)r   r   r   r   r   ÚdateÚtimeÚdecimalÚDecimalÚuuidÚUUIDr   r   Ústrr   Ú__classcell__r   r   r#   r	   r   !   s    
úr   c                 K   s,   |st }|| fd|ptit|fi |¤Ž¤ŽS )z Serialize object to json string.Úcls)Ú_json_extra_kwargsÚ_default_encoderÚdict)ÚsÚ_dumpsr-   Údefault_kwargsÚkwargsr   r   r	   Údumps@   s
   ÿr5   Tc                 C   sp   t | tƒr|  ¡  d¡} nt | tƒr|  d¡} n|r$t | tƒr$|  d¡} z|| ƒW S  ty7   t | ¡ Y S w )zDeserialize json from string.zutf-8)	r   Ú
memoryviewÚtobytesÚdecodeÚ	bytearrayÚbytesr
   ÚstdjsonÚloads)r1   Ú_loadsÚdecode_bytesr   r   r	   r<   H   s   



þr<   )r   r   r'   Újsonr;   r)   Údjango.utils.functionalr   r   ÚImportErrorr.   Ú	Exceptionr
   Ú
simplejsonÚsimplejson.decoderr   Útyper/   Ú_encoder_clsr   r5   r<   r   r   r   r	   Ú<module>   s6    ÿ
þý
	