3 �}:ah= � @ s� d Z ddlZddlZddlZddlmZmZ ddlZddlm Z m Z mZmZ ej e�ZG dd� d�ZG dd� dej�ZG d d � d ejejed�Zeed�d d�Zd dd�Zdd� Zd!dd�Zdd� Zdd� Zdd� Zdd� ZG dd� de�Z dS )"z�JSON (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)�Dict�Type)�b64�errors� interfaces�utilc @ sr e Zd ZdZdZdd d �Zedd� �Zd d� Zdd� Z dd� Z dd� Zdd� Zdd� Z edd� �Zedd� �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. � json_name�default� omitempty�fdec�fencNFc C s>