https://github.com/heartsucker/python-json-serde
JSON de/serializers
https://github.com/heartsucker/python-json-serde
deserialization json python serialization
Last synced: 5 months ago
JSON representation
JSON de/serializers
- Host: GitHub
- URL: https://github.com/heartsucker/python-json-serde
- Owner: heartsucker
- License: apache-2.0
- Created: 2018-07-06T15:09:59.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2021-01-15T09:48:47.000Z (over 5 years ago)
- Last Synced: 2025-08-29T05:35:26.662Z (10 months ago)
- Topics: deserialization, json, python, serialization
- Language: Python
- Homepage: https://pypi.org/project/json-serde/
- Size: 53.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# json-serde
[](https://pypi.python.org/pypi/json-serde) [](https://api.travis-ci.org/heartsucker/python-json-serde.svg?branch=develop) [](https://python-json-serde.readthedocs.io/en/latest/?badge=latest)
JSON de/serializer for Python, inspired by `attrs` and `SQLAlchemy`.
## Example
```python
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](./LICENSE-MIT)
and [LICENSE-APACHE](./LICENSE-APACHE) for details.