Deserialize to objects while staying DRY
Project description
Deserialize to objects while staying DRY.
Installation
pip install desert
Usage
To use Desert in a project:
from dataclasses import dataclass
# Or using attrs
# from attr import dataclass
from typing import List
import desert
@dataclass
class Person:
name: str
age: int
@dataclass
class Car:
passengers: List[Person]
# Load some simple data types.
data = {'passengers': [{'name': 'Alice', 'age': 21}, {'name': 'Bob', 'age': 22}]}
# Create a schema for the Car object.
schema = desert.schema(Car)
# Load the data.
car = schema.load(data)
assert car == Car(passengers=[Person(name='Alice', age=21), Person(name='Bob', age=22)])
Documentation
Changelog
0.1.0 (2019-06-22)
Changes
First release on PyPI.
—
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for desert-0.1.1.post3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59421e8c4f9d1cf2d31b07e5b0b173adae0f69d0c69b94522c361c02209944de |
|
MD5 | 03afb53e755ff5529cc943ce836d9ab3 |
|
BLAKE2b-256 | 9594c965d89e6876fa9762bab91e4afec2baaf3b9ffeedf728e29a41fc020e9f |