⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.30
Server IP:
45.79.8.107
Server:
Linux localhost 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.2-1ubuntu2.21
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3
/
dist-packages
/
josepy
/
__pycache__
/
View File Name :
json_util.cpython-310.pyc
o h9RaG @ s d Z ddlZddlZddlZddlmZmZmZmZm Z m Z mZ ddlm Z ddlZddlmZmZmZmZ eeZ d1deded ed eegef deegef defd dZG dd dZG dd deZG dd dejZG dd dejejedZ de!defddZ"d2dedee# dede!fddZ$de!defd d!Z%d2dedee# dede!fd"d#Z&d$ejj'defd%d&Z(d'edejj'fd(d)Z)d*ejj'defd+d,Z*d'edejj'fd-d.Z+G d/d0 d0e Z,dS )3zJSON (de)serialization framework. The framework presented here is somewhat based on `Go's "json" package`_ (especially the ``omitempty`` functionality). .. _`Go's "json" package`: http://golang.org/pkg/encoding/json/ N)DictTypeAnyCallableListMappingOptional)crypto)b64errors interfacesutilF json_namedefault omitemptydecoderencoderreturnc C s t | ||||dS )a4 Convenient function to declare a :class:`Field` with proper type annotations. This function allows to write the following code: import josepy class JSON(josepy.JSONObjectWithFields): typ: str = josepy.field('type') def other_type(self) -> str: return self.typ r r r r r )_TypedFieldr r 2/usr/lib/python3/dist-packages/josepy/json_util.pyfield s r c @ s e Zd ZdZdZ d#dedededeegef d eegef d dfddZ e d ed efddZd ed efddZded d fddZ deegef d d fddZdeegef d d fddZd ed efddZd ed efddZe d ed efdd Ze d ed efd!d"ZdS )$Fielda JSON object field. :class:`Field` is meant to be used together with :class:`JSONObjectWithFields`. ``encoder`` (``decoder``) is a callable that accepts a single parameter, i.e. a value to be encoded (decoded), and returns the serialized (deserialized) value. In case of errors it should raise :class:`~josepy.errors.SerializationError` (:class:`~josepy.errors.DeserializationError`). Note, that ``decoder`` should perform partial serialization only. :ivar str json_name: Name of the field when encoded to JSON. :ivar default: Default value (used when not present in JSON object). :ivar bool omitempty: If ``True`` and the field value is empty, then it will not be included in the serialized JSON object, and ``default`` will be used for deserialization. Otherwise, if ``False``, field is considered as required, value will always be included in the serialized JSON objected, and it must also be present when deserializing. )r r r fdecfencNFr r r r r r c C sD || _ || _|| _|d u r| jn|| _|d u r| j| _d S || _d S N)r r r default_decoderr default_encoderr )selfr r r r r r r r __init__B s zField.__init__valuec C s t |t o| S )zIs the provided value considered "empty" for this field? This is useful for subclasses that might want to override the definition of being empty, e.g. for some more exotic data types. ) isinstanceboolclsr! r r r _emptyM s zField._emptyc C s | |o| jS )zOmit the value in output?)r&