Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heartsucker/python-json-serde
JSON de/serializers
https://github.com/heartsucker/python-json-serde
deserialization json python serialization
Last synced: about 1 month 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 (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2021-01-15T09:48:47.000Z (almost 4 years ago)
- Last Synced: 2024-11-21T04:49:02.624Z (about 2 months ago)
- Topics: deserialization, json, python, serialization
- Language: Python
- Homepage: https://pypi.org/project/json-serde/
- Size: 53.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# json-serde
[![PyPI Version](https://badge.fury.io/py/json-serde.png)](https://pypi.python.org/pypi/json-serde) [![CI](https://api.travis-ci.org/heartsucker/python-json-serde.svg?branch=develop)](https://api.travis-ci.org/heartsucker/python-json-serde.svg?branch=develop) [![Documentation Status](https://readthedocs.org/projects/python-json-serde/badge/?version=latest)](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, IsoDateTimeclass 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.