https://github.com/cosven/april
一个失败但是还算好玩的玩具
https://github.com/cosven/april
deserialization json model python
Last synced: 2 months ago
JSON representation
一个失败但是还算好玩的玩具
- Host: GitHub
- URL: https://github.com/cosven/april
- Owner: cosven
- License: mit
- Created: 2017-04-27T14:59:05.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-23T18:21:26.000Z (about 8 years ago)
- Last Synced: 2025-03-13T01:36:46.080Z (over 1 year ago)
- Topics: deserialization, json, model, python
- Language: Python
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# april
[](https://travis-ci.org/cosven/april)
[](https://coveralls.io/github/cosven/april?branch=master)
lightweight & declarative model/struct representation, work as you expected it to
## Usage
### simple usage
```python
from datetime import datetime
from april import Struct
class User(Struct):
_fields = ['name', 'age', 'birthday']
user = UserModel(name='lucy', age=20, birthday='2017-09-08')
user2 = UserModel(name='hey')
class VIP(User):
_fields = ['level']
vip = VIP(user, level=1)
vip.name == lucy
user2.age is None
```
> tips: `april` usually works along with serialization library, such as [marshmallow](http://marshmallow.readthedocs.io/en/latest/quickstart.html#deserializing-to-objects)