Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
json_serde
tests
.gitignore
.travis.yml
CHANGELOG.md
LICENSE-APACHE
LICENSE-MIT
MANIFEST.in
Makefile
README.md
setup.cfg
setup.py
tox.ini

README.md

json-serde

PyPI Version CI Documentation Status

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.