Пример #1
0
    def to_dict(self, item, **kwargs):
        # Convert `item` to `data` dictionary
        data = Format.to_dict(self, item, **kwargs)

        # Encode dictionary with minimized data protocol
        return self.encode(item.__class__, data)
Пример #2
0
    def from_dict(self, collection, model, encoded, children=True, **kwargs):
        # Decode dictionary with minimized data protocol
        data = self.decode(model, encoded, children=children, **kwargs)

        # Parse `model` from `data`
        return Format.from_dict(self, collection, model, data, **kwargs)