JSON de/serializers
Project description
json-serde
JSON de/serializer for Python, inspired by attrs
and SQLAlchemy
.
Example
import requests
from json_serde import JsonSerde, Integer, String, IsoDateTime
class User(JsonSerde):
username = String()
user_id = Integer(rename='userId')
birthday = IsoDateTime(is_optional=True, default=None)
resp = requests.get('https://example.com/api/user')
resp.raise_for_status()
api_response = resp.json()
# {'username': 'emmag', 'userId': 1312, 'somethingElse': ['irrelevant']}
user = User.from_json(api_response)
assert user.username == 'emmag'
assert isinstance(user.user_id, int)
assert user.birthday is None
License
This work is dual licensed under the MIT and Apache-2.0 licenses. See LICENSE-MIT and LICENSE-APACHE for details.
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 Distribution
json-serde-0.0.10.tar.gz
(10.2 kB
view hashes)
Built Distribution
Close
Hashes for json_serde-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cbbeb87a770d30f5f9e181b2bca44f2d2234db1b55652a9dd10629615b4e057 |
|
MD5 | d780fecdcb5d687d306fd57aa7bbd7c8 |
|
BLAKE2b-256 | ef59b1c94da79954b5fe3e19cff2d15f4c4941d1e8c704c84ecc97f0a3792dbf |