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(optional=True)
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.0.tar.gz
(9.0 kB
view hashes)
Built Distribution
Close
Hashes for json_serde-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5644e3dd0ff33a2a5aa6d9b5706bc799dde1f3767db9d84c31cbb351b093b5f |
|
MD5 | a8bbf328177d3cda4f612a98014b1245 |
|
BLAKE2b-256 | 0f58cf2922c9cb827f104c700948bb9eb20454ca664ac2202b2a3adf7b50b3d8 |